Linearithmic Sorts
- Summary of Linearithmic Sorts.
We add another sorting strategy, the Quicksort, to our repertoire of linearithmic sorts.
Name | Description | Average Case |
---|---|---|
Heapsort | Build a max-heap from the sequence (bottom-up heapify). Remove the max and swap it to the end of the collection where the "leaf" was removed. Repeat the last step times. | |
Merge Sort | Divide the sequence into subsequences of singletons. Successively merge the subsequences pairwise until a single sequence is reformed. | |
Quicksort | Pick an element from the sequence (the pivot), partition the remaining elements into those greater than and less than this pivot. Repeat this for each partition (recursively). |
As noted here, "quicksort has running time in the worst case, but it is typically . Indeed, in practical situations, a finely tuned implementation of quicksort beats most sorting algorithms, including those whose theoretical complexity is in the worst case.