Notes
Pattern defeating quicksort is a hybrid sorting algorithm with the following goals:
- memory usage.
- fast average case
- deterministically avoids bad worst case behavior
- Runs in linear time for a few patterns
It is also still unstable.
Pattern defeating quicksort uses insertion sort for small data sets due to its good performance even with complexity. It then has quicksort as the second sort, and heapsort as the fallback sort.
The quicksort uses a median of three pivot selection scheme, with two additions:
- defining a “bad partition” and tracking that, and swapping a couple of elements to break bad patterns.
- handling ascending/descending sequences with little overhead.