LOGBOOK

HELP

Quiz Entry - updated: 2026.11.27

What does the $\Omega(n\log n)$ lower bound say about merge-sort, heap-sort and quick-sort, and what does it not say?

Merge-sort and heap-sort need $O(n\log n)$ comparisons even in the worst case, matching the bound, so no comparison sort can beat them by more than a constant factor: they are asymptotically optimal. Quick-sort is optimal in the expected case. The bound limits the worst and the average case, not lucky inputs.

The bound is a statement about the height of the decision tree, its longest path. It does not forbid short paths: insertion-sort on an already sorted list makes only $n - 1$ comparisons, because that input happens to follow a short path to its leaf. What the bound guarantees is that some input of size $n$ needs about $n\log_2 n$ comparisons, whatever the algorithm.

It also holds on average over all $n!$ input orders: in a binary tree with $n!$ leaves the average leaf depth is also at least $\log_2(n!)$. No comparison sort is faster than $n\log n$ on average either, which makes quick-sort's expected $O(n\log n)$ optimal too, even though its worst case is $O(n^2)$.

"Asymptotically optimal" leaves room for constants. Merge-sort, heap-sort and quick-sort all sit at $n\log n$; which of them is fastest in practice is decided by constant factors, memory behaviour and the input, not by the bound.

Go deeper:

From Quiz: ADS / Sorting Lower Bound, Bucket-Sort and Radix-Sort | Updated: Nov 27, 2026