Heap Sort
Senior insight
The only O(n log n) comparison sort that is strictly in-place (O(1) aux). Not stable. Loses to merge-sort and quicksort in wall-clock time because of poor cache behavior — the sift-down jumps around the array.
Common traps
- Assuming it is stable — it is not
- Using it when the array fits in cache and quicksort would be ~2× faster
Follow-up questions
- ? Why is heap-sort slower than quicksort in practice despite the same asymptotic bound?