update
This commit is contained in:
parent
1f1ad49427
commit
6f050a029e
2496 changed files with 37609 additions and 3031 deletions
|
|
@ -0,0 +1,5 @@
|
|||
QuickSort[x_List] := Module[{pivot},
|
||||
If[Length@x <= 1, Return[x]];
|
||||
pivot = RandomChoice@x;
|
||||
Flatten@{QuickSort[Cases[x, j_ /; j < pivot]], Cases[x, j_ /; j == pivot], QuickSort[Cases[x, j_ /; j > pivot]]}
|
||||
]
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
qsort[{}] = {};
|
||||
qsort[{x_, xs___}] := Join[qsort@Select[{xs}, # <= x &], {x}, qsort@Select[{xs}, # > x &]];
|
||||
Loading…
Add table
Add a link
Reference in a new issue