The Ω(n lg n) comparison-sort lower bound
◈ 4 cardsThe decision-tree model: ≥ n! leaves ⇒ height ≥ lg(n!) = Ω(n lg n); merge sort and heapsort are provably optimal — within this model.
Why can't we beat by comparing?
Insertion sort, merge sort, heapsort, and quicksort are all comparison sorts: they learn the order only by asking questions of the form "?" — they never look at the values themselves. This lesson proves a hard limit: any comparison sort needs comparisons in the worst case. It's not a failure of cleverness — it's information-theoretic.
The decision-tree model
Model a comparison sort as a decision tree: a full binary tree where each internal node is a comparison "", the left branch is taken when and the right when , and each leaf is the permutation the algorithm outputs along that path. Running the algorithm on one input = tracing one root-to-leaf path; the number of comparisons on that input = the path length. The worst-case comparison count is the tree's height .
The proof (Theorem 8.1)
A correct sort must produce all orderings, so the tree needs at least reachable leaves. A binary tree of height has at most leaves. Combining:
where is Stirling's approximation. Hence : every comparison sort makes comparisons in the worst case. Each comparison yields at most one bit ("" or ""), and distinguishing outcomes needs bits — that is the deep reason.
What it buys us
Corollary: merge sort and heapsort run in (matching the bound), so they are asymptotically optimal comparison sorts — no comparison-based method can do better than a constant factor. The bound is model-specific: it constrains only comparison sorts. The next lesson breaks by not comparing.
Worked example
For : , and a binary tree needs height to hold 6 leaves — so 3 elements need at least 3 comparisons in the worst case, which insertion sort exactly achieves.