Oddly, the Haskell version of Quicksort is probably the easiest to understand:
qsort [] = [] qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)The first line reads: the result of sorting an empty list ([]) is an empty list.
The second line reads: to sort a list whose first element is x and the rest of which is called xs, sort the elements of xs that are less than x, sort the elements of xs that are greater than or equal to x, and concatenate (++) the results with x sandwiched in the middle.
To learn more about quicksort’s behaviour see Eppstein’s paper. QuickSort source code download..
|
|
available on the web at: |
http://mindprod.com/jgloss/quicksort.html |
optional Replicator mirror
|
J:\mindprod\jgloss\quicksort.html | |
![]() |
Please email your
feedback for publication,
letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear
wording, broken/redirected link reports, suggestions to improve this page or comments to
Roedy Green :
| |
| Blog | Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[107.22.127.92] |
|
| Feedback | You are visitor number 34,399. | |