This page is a shooting range . The parent note on T(n) = aT(n / b) + f(n) gave you the three cases. Here we fire a bullet at every target: each case, the tricky ties, the degenerate inputs (a = 1 , f constant), the log-gap trap that lives between the cases, a real-world word problem, and an exam-style twist that looks like one case but is another.
Before any example, three reminders in plain words so nothing is used before it is built.
Definition The three comparison words (Big-O, Big-Ω, Big-Θ)
These are the "rulers" we use to compare two growth rates. Full machinery lives in Big-O, Big-Omega, Big-Theta ; here is the one-line meaning we lean on:
g ( n ) = O ( h ( n )) means g grows no faster than h (an upper bound, "g ≤ some constant × h " for big n ). Think: ceiling .
g ( n ) = Ω ( h ( n )) means g grows at least as fast as h (a lower bound). Think: floor .
g ( n ) = Θ ( h ( n )) means g grows exactly like h (ceiling and floor together, same rate). Think: sandwich .
So Case 1 needs f below the ruler (O ), Case 3 needs f above it (Ω ), and Case 2 needs f equal to it (Θ ).
Definition The race, in words
Every divide-and-conquer recurrence
T ( n ) = a T ( n / b ) + f ( n )
is a fight between two piles of work:
the leaf pile , whose size is n l o g b a (this many tiny subproblems at the bottom of the tree), and
the combine pile f ( n ) (the sorting/gluing you do yourself at the top).
a = how many subproblems you spawn. b > 1 = how fast the input shrinks . f ( n ) = work outside the recursion . The symbol log b a means "the power you raise b to, to get a " — the exponent that measures how fast leaves multiply.
Definition The regularity condition (needed for Case 3, cell D)
Case 3 has a second door beyond "f is bigger": you must also confirm
a f ( n / b ) ≤ c f ( n ) for some constant c < 1 and all large n .
In words: one level down costs a fixed fraction less than the level above it, so the level-costs shrink as you descend and the whole tree's cost collapses onto the root. Without this, an oscillating f could refuse to settle. For ordinary polynomial f it always holds — but you must state it.
Look at the picture below: the same recursion tree drawn three ways. The red shape is whichever pile wins. That single picture is the whole theorem.
Figure s01 — a horizontal bar chart shown in three side-by-side panels; each panel stacks five bars, one per tree level, with the root at the top and the leaf row at the bottom, and the bar length is the total work done on that level. Left panel (Case 1, leaves win): bars grow longer as you go down, and the longest bar — the bottom leaf row — is drawn in red, so the leaf pile dominates. Middle panel (Case 2, tie): all five bars are the same length and each is outlined in red, showing every floor costs the same, so you pay per floor (× log n ). Right panel (Case 3, root wins): bars shrink as you go down, and the longest bar — the top root row — is drawn in red, so the root/combine pile dominates. A red arrow in each panel points at the winning bar with a short label ("leaf pile biggest" / "all floors equal" / "root pile biggest").
Every recurrence the basic theorem can eat falls into exactly one of these cells. The examples that follow are each tagged with the cell they hit, so you can see the whole board is covered.
Cell
What makes it this cell
Answer shape
Example #
A — Case 1, leaves win
f polynomially smaller than n l o g b a
Θ ( n l o g b a )
1
A′ — Case 1, degenerate f = Θ ( 1 )
constant combine, a > 1
Θ ( n l o g b a )
2
B — Case 2, plain tie
f = Θ ( n l o g b a ) , no extra log
Θ ( n l o g b a log n )
3
C — Case 2, degenerate a = 1
tree is a single stick, n l o g b a = n 0 = 1
Θ ( log n )
4
D — Case 3, root wins
f polynomially bigger + regularity holds
Θ ( f ( n ))
5
E — Case 3 regularity fails
f bigger but a f ( n / b ) ≤ c f ( n )
theorem refuses; must fall back
6
F — the log-gap trap
f bigger only by a log , not a polynomial
extended Case 2, Θ ( n l o g b a log k + 1 n )
7
G — real-world word problem
translate prose → a , b , f first
whichever case results
8
H — exam twist (looks like X, is Y)
disguised leaf cost / hidden log
trap-aware answer
9
The "signs/quadrants" of this topic are which pile wins (leaves / tie / root); the degenerate inputs are a = 1 (single stick, cell C) and f = Θ ( 1 ) (constant combine, cell A′). We hit them all.
Example 1 — Cell A (leaves win) · T ( n ) = 8 T ( n /2 ) + n 2
Forecast: eight subproblems is a lot — guess the leaves swamp the tiny n 2 combine. Guess n 3 -ish. Write your guess down before reading on.
Read off constants. a = 8 , b = 2 , f ( n ) = n 2 .
Why this step? The theorem only sees a , b , f ; everything starts by naming them.
Compute the leaf exponent. log b a = log 2 8 = 3 , so leaf cost = n 3 .
Why this step? n l o g b a is the ruler we compare f against — nothing else matters until we have it.
Compare f to the ruler. f ( n ) = n 2 versus n 3 . Since n 2 = O ( n 3 − ϵ ) (take ϵ = 1 ), f is polynomially smaller .
Why this step? "Polynomially smaller" = smaller by a genuine power of n , which is exactly the trigger for Case 1 (leaves dominate).
Apply Case 1. T ( n ) = Θ ( n l o g b a ) = Θ ( n 3 ) .
Verify: count the leaves directly — 8 l o g 2 n = n l o g 2 8 = n 3 . The bottom row alone already costs n 3 , so the answer can't be smaller. Guess confirmed. ✓
Example 2 — Cell A′ (degenerate constant combine) · T ( n ) = 2 T ( n /2 ) + 1
Forecast: two subproblems each level, but the combine is a mere constant. Does constant f mean the answer is constant? Or do the leaves take over? Guess first — this is the counterpart to Binary Search but with branching .
Read off constants. a = 2 , b = 2 , f ( n ) = 1 = Θ ( 1 ) .
Why this step? Naming a , b , f is always first; here f is a constant , the degenerate combine we promised to cover.
Compute the leaf exponent. log 2 2 = 1 , so leaf cost = n 1 = n .
Why this step? We must build the ruler before we can see whether the constant f sits below or on it.
Compare f to the ruler. f ( n ) = 1 versus n . A constant is O ( n 1 − ϵ ) (take ϵ = 1 , then n 0 = 1 — still O of the same order, and any ϵ < 1 gives strict polynomial smallness). So f is polynomially smaller → Case 1.
Why this step? This is the key lesson of the cell: a constant f almost always loses to a branching tree , because a > 1 makes the leaf count grow like a real power of n while f stays flat.
Apply Case 1. T ( n ) = Θ ( n l o g b a ) = Θ ( n ) .
Verify: count nodes in the whole tree — a full binary tree with n leaves has about 2 n − 1 nodes, each doing O ( 1 ) work, so total = Θ ( n ) . Constant combine, linear answer — the leaves ran the show. ✓
Example 3 — Cell B (plain tie) · Merge-style · T ( n ) = 4 T ( n /2 ) + n 2
Forecast: four subproblems, each half-size, combine cost n 2 . Does the n 2 combine tie the leaves? Guess first.
Read off constants. a = 4 , b = 2 , f ( n ) = n 2 .
Why this step? The theorem sees only a , b , f ; we must name them before any comparison is possible.
Compute the leaf exponent. log 2 4 = 2 , so leaf cost = n 2 .
Why this step? We build the ruler n l o g b a first because Case 2 is defined by f matching this ruler — we can't spot a tie without it.
Compare. f ( n ) = n 2 = Θ ( n 2 ) = Θ ( n l o g b a log 0 n ) . Exact match with k = 0 .
Why this step? When f equals the ruler (Θ , not O or Ω ), no pile wins; every level of the tree costs the same, so we're in Case 2.
Apply Case 2. T ( n ) = Θ ( n 2 log 0 + 1 n ) = Θ ( n 2 log n ) .
Why the log ? Look at figure s01, middle panel : each floor is the same length, and there are log 2 n floors, so total = (per-floor cost) × (number of floors).
Verify: at n = 16 , floors = log 2 16 = 4 , each floor ≈ 1 6 2 = 256 , total ≈ 4 × 256 = 1024 . And n 2 log 2 n = 256 × 4 = 1024 . Matches. ✓
Example 4 — Cell C (degenerate a = 1 ) · Binary Search · T ( n ) = T ( n /2 ) + 1
Forecast: you throw away half the array and do O ( 1 ) work. Guess log n . This is Binary Search .
Read off constants. a = 1 , b = 2 , f ( n ) = 1 .
Why this step? Naming a , b , f is the fixed opening move; note a = 1 , the single-stick degenerate input.
Compute the leaf exponent. log 2 1 = 0 , so leaf cost = n 0 = 1 .
Why this step? a = 1 means the tree is a single stick — one node per level, not a branching tree — and n 0 = 1 says the leaf count is literally 1 . We need this ruler to see it's a tie, not a win.
Compare. f ( n ) = 1 = Θ ( n 0 log 0 n ) . A tie at the constant level, k = 0 .
Why this step? Both piles are constant (Θ of each other), so neither dominates → Case 2.
Apply Case 2. T ( n ) = Θ ( n 0 log 0 + 1 n ) = Θ ( log n ) .
Verify: unroll by hand — T ( n ) = 1 + 1 + ⋯ + 1 once per halving, and you can halve n down to 1 exactly log 2 n times. Sum = log 2 n = Θ ( log n ) . ✓
Example 5 — Cell D (root wins, regularity holds) · T ( n ) = 2 T ( n /2 ) + n 2
Forecast: only two subproblems but an expensive n 2 combine. The combine should swamp the leaves. Guess n 2 .
Read off constants. a = 2 , b = 2 , f ( n ) = n 2 .
Why this step? Fixed opening move — the theorem only reads a , b , f .
Compute the leaf exponent. log 2 2 = 1 , leaf cost = n 1 .
Why this step? We need the ruler to see that f = n 2 sits above it — the trigger for Case 3.
Compare. f ( n ) = n 2 = Ω ( n 1 + ϵ ) with ϵ = 1 — polynomially bigger .
Why this step? Bigger-by-a-real-power (Ω with a genuine exponent gap) is the trigger for "root wins", but Case 3 is the only case with a second door — regularity.
Regularity check. a f ( n / b ) = 2 ( 2 n ) 2 = 2 n 2 = 2 1 f ( n ) ≤ c f ( n ) with c = 2 1 < 1 . ✓
Why this step? Regularity (the condition we defined above) guarantees the geometric series of level-costs shrinks going down, so it converges to the top term instead of blowing up.
Apply Case 3. T ( n ) = Θ ( f ( n )) = Θ ( n 2 ) .
Verify: the root alone costs n 2 , and each lower level costs at most half the one above (2 1 , 4 1 , … ), a decreasing Geometric Series summing to ≤ 2 n 2 . So total = Θ ( n 2 ) . ✓
Example 6 — Cell E (regularity FAILS) · T ( n ) = 2 T ( n /2 ) + n 2 ∣ sin n ∣ ⚠
Forecast: f looks bigger than the n 1 ruler, so you may reach for Case 3. Pause — is it always bigger?
Read off constants. a = 2 , b = 2 , and f ( n ) = n 2 ∣ sin n ∣ , leaf ruler n 1 .
Why this step? Even for a trap recurrence, naming a , b , f and the ruler is where we start.
Try the Ω condition. ∣ sin n ∣ dips arbitrarily close to 0 , so f ( n ) is not bounded below by n 1 + ϵ at those points.
Why this step? Case 3 needs f = Ω ( n l o g b a + ϵ ) for all large n ; an oscillating f breaks this lower bound.
Try regularity anyway. a f ( n / b ) = 2 ⋅ 4 n 2 ∣ sin ( n /2 )∣ = 2 n 2 ∣ sin ( n /2 )∣ . Because sin ( n /2 ) and sin n are uncorrelated in sign/size, no fixed c < 1 makes a f ( n / b ) ≤ c f ( n ) hold for all large n .
Why this step? If regularity can fail infinitely often, the level-cost series need not converge to the root — so Case 3's conclusion is unjustified.
Verdict. The basic Master Theorem does not apply. Fall back to a recursion tree bound or Akra–Bazzi method , which handle irregular f .
Verify: this is a negative result — the check is that the two Case-3 preconditions genuinely fail, which we showed in steps 2–3. Lesson: a bigger-looking f is not enough; you must earn Case 3 twice. ✓ (nothing numeric to plug)
Example 7 — Cell F (the log-gap trap) · T ( n ) = 2 T ( n /2 ) + n log n
Forecast: n log n is bigger than the ruler n … so Case 3, answer n log n ? Write that tempting guess down — then watch it fail.
Read off constants. a = 2 , b = 2 , f ( n ) = n log n ; ruler = n l o g 2 2 = n .
Why this step? Name a , b , f and build the ruler before judging the gap.
Test Case 3's Ω . Is n log n = Ω ( n 1 + ϵ ) for some ϵ > 0 ? No! For any ϵ > 0 , n ϵ eventually beats log n , so n log n is smaller than n 1 + ϵ . The gap is only a log , not a polynomial .
Why this step? Case 3 demands a polynomial margin (Ω with a real exponent). A log margin lands in the crack between the cases.
Recognize extended Case 2. f ( n ) = n log n = Θ ( n 1 log 1 n ) , so k = 1 .
Why this step? Extended Case 2 is exactly the tool for f = Θ ( n l o g b a log k n ) — it fills the crack the basic three cases leave open.
Apply. T ( n ) = Θ ( n log k + 1 n ) = Θ ( n log 2 n ) .
Verify: the level-costs are n log n , n log ( n /2 ) , … — nearly equal across all log 2 n levels. Summing ≈ n log n over log n levels gives ∼ n log 2 n . The naive "n log n " undercounts by a whole log factor. ✓
Example 8 — Cell G (real-world word problem)
"A photo-sharing app builds a thumbnail collage. To render a collage of n photos it splits the photos into 3 equal groups, recursively renders each group's sub-collage, then stitches the 3 results with an edge-blend that costs Θ ( n ) per stitch. What is the render time?"
Forecast: three sub-jobs, each a third the size, linear stitch. Guess before computing.
Translate prose to a , b , f . "split into 3 groups" → a = 3 . "each a third the size" → b = 3 . "stitch costs Θ ( n ) " → f ( n ) = n .
Why this step? The hard part of word problems is reading off the recurrence; the algebra is easy once a , b , f are named.
Write the recurrence. T ( n ) = 3 T ( n /3 ) + n .
Why this step? Getting to the standard form a T ( n / b ) + f ( n ) is what lets the theorem apply at all.
Compute the leaf exponent. log 3 3 = 1 , leaf cost = n .
Why this step? Build the ruler so we can compare the linear stitch against it.
Compare. f ( n ) = n = Θ ( n 1 log 0 n ) — an exact tie (Θ ), k = 0 → Case 2.
Why this step? Same drill as Example 3; the tie means every floor costs the same Θ ( n ) .
Answer. T ( n ) = Θ ( n log n ) . The app renders in n log n time — same class as Merge Sort .
Verify: at n = 27 : log 3 27 = 3 floors, each ≈ 27 , total ≈ 81 ; and n log 3 n = 27 × 3 = 81 . Matches. ✓
Example 9 — Cell H (exam twist: looks like Case 1, is Case 2) · T ( n ) = 4 T ( n /2 ) + n 2 / log n
Forecast: n 2 / log n is smaller than the ruler n 2 — so Case 1, answer n 2 ? That's the bait.
Read off constants. a = 4 , b = 2 ; f ( n ) = n 2 / log n .
Why this step? Name a , b , f first — the twist hides in f , so we must see it plainly.
Compute the leaf exponent. log 2 4 = 2 , ruler = n 2 .
Why this step? We need the ruler to measure how far f sits below it — and whether that gap is polynomial or just a log.
Test Case 1's O . Case 1 needs f = O ( n 2 − ϵ ) — smaller by a polynomial . But n 2 / log n is only smaller by a log , not a power (n 2 − ϵ eventually beats n 2 / log n from below). So Case 1 does not apply.
Why this step? Just like Example 7 but mirrored — the gap between f and the ruler is a log, so the basic case's polynomial requirement fails.
Read it as extended Case 2 with negative k . f ( n ) = n 2 log − 1 n = Θ ( n 2 log − 1 n ) , i.e. k = − 1 .
Why this step? Extended Case 2 permits k = − 1 (a special sub-case): when k = − 1 the answer is Θ ( n l o g b a log log n ) , not the usual log k + 1 n .
Apply the k = − 1 rule. T ( n ) = Θ ( n 2 log log n ) .
Verify: the level costs form the series ∑ l o g ( n / 2 i ) n 2 , and summing 1/ log terms over log n levels grows like log log n (a harmonic-of-logs sum), giving n 2 log log n — strictly above the naive n 2 of the Case-1 trap. ✓
Recall One-line lesson per cell (click to reveal)
A: many subproblems, cheap combine → count leaves, Θ ( n l o g b a ) .
A′: constant f with a > 1 → leaves still win, Θ ( n l o g b a ) (Case 1).
B: f equals the ruler → tie → × log n .
C: a = 1 single stick, ruler is 1 → Θ ( log n ) .
D: big f and regularity → Θ ( f ) .
E: big-looking but oscillating f → theorem refuses; use Akra–Bazzi.
F: bigger only by a log → extended Case 2, extra log .
G: word problems = translate to a , b , f first, then it's routine.
H: smaller only by a log → still Case 2 (k = − 1 ), Θ ( n l o g b a log log n ) .
Mnemonic The two "only-a-log" traps are mirror images
Ruler-then-log-bigger → Example 7 → extra log .
Ruler-then-log-smaller → Example 9 → log log .
Both prove the same moral: Cases 1 and 3 demand a polynomial gap; a mere log gap always lands you back in Case 2.
Parent topic
Recursion Trees — the fallback when a cell (like E) breaks the theorem.
Akra–Bazzi method — handles the oscillating-f Example 6.
Big-O, Big-Omega, Big-Theta — the O /Ω/Θ language every comparison used.
Geometric Series — why leaves/tie/root correspond to shrinking/flat/growing series.
Merge Sort , Binary Search , Karatsuba Multiplication — real algorithms behind cells B, C, A.