(Can you spot what the model says and where it applies?)
Recall Solution 1.1
A comparison sort decides order using only questions of the form "is ai<aj?" — never reading the numeric value of a key.
(a) Bubble sort — yes. It swaps adjacent items based on a comparison.
(b) Counting sort — no. It does count[x]++, using the value x as an array index.
(c) Heapsort — yes. Sift-up/sift-down compare children to parents.
(d) Radix sort — no. It buckets by digit value, not by comparison.
(e) Quicksort — yes. Partitioning compares each element to a pivot.
Rule of thumb: if it ever looks at a value (to index, hash, or arithmetic), it escapes the model. See Counting Sort and Radix Sort for the escapees, Merge Sort · Heapsort · Quicksort for the comparison crowd.
Recall Solution 1.2
(a) An internal node is a single comparison of two elements ai and aj — i.e. the question "is ai<aj?".
(b) A leaf is one output permutation — the ordering the algorithm commits to once it reaches that leaf.
Each internal node has 2 children, because the comparison "is ai<aj?" has exactly two outcomes (yes/<, or no/≥). That two-ness is the whole reason the tree is binary, and why height h (the longest root-to-leaf path, from the reminder above) allows at most 2h leaves.
We need enough leaves: leaves ≥4!=24. A tree of height h has at most 2h leaves, so we need
2h≥24⟹h≥log224≈4.585⟹h≥⌈4.585⌉=5.24=16<24, so height 4 is impossible; 25=32≥24 is feasible. Minimum worst-case comparisons =5. (And indeed an optimal 4-element sort achieves exactly 5.)
Recall Solution 2.2
5!=120. So ⌈log2120⌉=⌈6.907⌉=7.
The bound forces height ≥7. But it does not guarantee a tree of height exactly 7 exists — the bound is necessary, not automatically sufficient. (In fact, for n=5 the optimal is 7, so here they coincide, but for e.g. n=12 the true optimum exceeds ⌈log2n!⌉.)
Recall Solution 2.3
Need leaves ≥8!=40320. With height 9: 29=512≪40320. Since 512<40320, a height-9 tree can distinguish at most 512 orderings, far short of the 40320 required. The claim is impossible. You need h≥⌈log240320⌉=⌈15.3⌉=16 comparisons.
(Reason about the tree's shape and the bound's structure.)
Recall Solution 3.1
log2(n!) (blue) is the true information content — the exact minimum height.
nlog2n (yellow) is the leading term of Stirling's Approximation. The key fact inline: Stirling says log2(n!)=nlog2n−nlog2e+O(logn), where log2e≈1.4427. So the gap between the blue and yellow curves is ≈1.44n — linear, hence swallowed by the nlogn term for large n: the curves hug each other.
2nlog22n (red) is the crude bound: keep only the top half of the factors of n!, each ≥n/2, so n!≥(n/2)n/2 and log2(n!)≥2nlog22n. It sits belowlog2(n!) (we threw factors away) but still grows as a constant times nlogn.
"Ω(nlogn)" (from the reminder: a lower bound up to a constant factor) only asks for some positive constant c with log2(n!)≥cnlogn for large n. The crude red curve already delivers such a c (roughly 1/2). So even the wasteful bound proves the theorem — we never needed Stirling for the lower bound, only for the sharp constant.
Recall Solution 3.2
False, in general. A complete balanced tree of height h has exactly 2h leaves, yes. But a valid sorting tree needs exactly n! leaves, and n! is almost never a power of 2 (only n≤2). So the minimum-height tree cannot be perfectly balanced — some root-to-leaf paths are shorter than h. The bound uses only the inequality leaves ≤2h; it never claims the tree is full — the "used ≤, not =" subtlety.
Recall Solution 3.3
A ternary tree of height h has at most 3h leaves. Combining with leaves ≥n!:
3h≥n!⟹h≥log3(n!)=log23log2(n!).
Since log23≈1.585 is a constant, log3(n!)=Θ(log2(n!))=Θ(nlogn) (recall Θ ignores constant factors). The asymptotic bound is unchanged — only the constant shrinks by a factor log23. Any fixed number of outcomes per node gives the same Ω(nlogn).
Model the search as a binary decision tree where each internal node compares the target to some array element. Now the possible outcomes are the positions the target could occupy — there are n+1 of them (before element 1, between 1 and 2, …, after element n). So we need
leaves≥n+1,2h≥n+1⟹h≥log2(n+1)=Ω(logn).
The difference from sorting: searching has ∼n outcomes, so log2n questions; sorting has n! outcomes, so log2(n!)≈nlog2n questions. Binary Search achieves ⌈log2(n+1)⌉, hence is optimal. This is exactly the classic "Height ≥log2n, not log2n!" confusion — the mistake was using the search count for the sort problem.
Recall Solution 4.2
Key fact inline (from Information Theory & Entropy): a uniform distribution over M equally-likely outcomes has entropyH=log2M bits — the average number of yes/no questions to identify one outcome. Here M=n!, so
H=log2(n!) bits.
To output the correct permutation with certainty, the algorithm must resolve all H bits. Each comparison returns one of two outcomes, giving at most 1 bit. So the number of comparisons in the worst case is ≥H=log2(n!) — the same bound, now read as "you can't extract more bits than you ask for."
For n=6: 6!=720, so H=log2720≈9.492 bits, i.e. at least ⌈9.492⌉=10 comparisons.
Recall Solution 4.3
The result is one sorted list of 2m elements; the "unknown" is how the two lists interleave. The number of interleavings is (m2m) (choose which m of the 2m output slots hold the first list's elements — see the figure above). So
2h≥(m2m)⟹h≥log2(m2m).
Using (m2m)≥2m+122m (a standard bound), log2(m2m)≥2m−log2(2m+1)=Ω(m). So merging needs Ω(m) comparisons — matching the Θ(m) merge step inside Merge Sort.
Fact (balanced-tree / Kraft bound): In any binary tree with L leaves at depths d1,…,dL, the average depth dˉ=L1∑idi≥log2L. (Intuition: a tree can't beat the perfectly balanced one, whose every leaf is at depth log2L; making some leaves shallower forces others deeper by more.)
Apply with L=n!. Assuming each of the n! inputs is equally likely, the average number of comparisons equals the average leaf depth dˉ:
dˉ≥log2(n!)≥2nlog22n=Ω(nlogn).
So even on average, comparison sorting costs Ω(nlogn). This closes the caveat that "a lucky input can finish in O(n)" — most inputs cannot; the lucky ones are a vanishing fraction.
Recall Solution 5.2
Each median query has 3 outcomes, so after q queries the tree has at most 3q leaves. We still must distinguish all n! orderings:
3q≥n!⟹q≥log3(n!)=log23log2(n!)=Ω(nlogn).
Same asymptotic wall — a constant-outcome oracle can shave the constant (here by 1/log23≈0.63) but never the nlogn growth. The lesson: only queries whose number of outcomes grows with the data can break the bound.
Recall Solution 5.3
Proof: (1) need ≥n! leaves (one per output permutation); (2) a binary tree of height h has ≤2h leaves; (3) so 2h≥n!, giving h≥log2(n!); (4) log2(n!)≥2nlog22n=Ω(nlogn).
(a) Heapsort runs in O(nlogn) comparisons — it meets the lower bound, so it's asymptotically optimal.
(b) Radix sort isn't a comparison sort (it buckets by digit value), so the model's premise fails and it may run in O(n) without contradiction.
Numbers:10!=3628800. log2(3628800)≈21.79, so ⌈⋅⌉=22. Crude bound 210log2210=5log25≈5(2.3219)=11.61. Note 11.61≤21.79 — the crude bound is genuinely below the true value yet still Ω(nlogn). ✔
Recall One-line summary to carry away
Count the distinct correct answers your tree must reach; take log2; that's your lower bound. For sorting it's log2(n!)=Ω(nlogn).