Expand description
Quicksort.
See the book entry Comparison sorting.
Functions§
- quicksort
- Sorts a slice using quicksort: a median-of-three pivot, Hoare’s partition (whose two scans
both stop at keys equal to the pivot, so runs of equal keys are split evenly rather than piling
up on one side), insertion sort for ranges of 16 or fewer, and recursion on the smaller side so
the stack depth is
O(log n). As in Musser’s introsort, a range still unsorted after2 log₂ npartitions is finished by heapsort, so the worst case isO(n log n)even on inputs built to defeat median-of-three.