Before we start, one reminder of the machine, so no symbol is unearned.
The single most-used algebra fact on this page:
The figure above shows the whole workflow as a funnel: the recurrence enters at the top, the residual is the "gunk" we must drain, and if the drain is ≤0 the bound survives.
For each recurrence, state a, b, and h(n) in the form T(n)=aT(n/b)+h(n).
(i) T(n)=3T(n/4)+n2 (ii) T(n)=T(n/2)+1 (iii) T(n)=4T(n/2)+n
Recall Solution
Just read off the pattern — no proof needed yet.
(i) a=3,b=4,h(n)=n2.
(ii) a=1,b=2,h(n)=1.
(iii) a=4,b=2,h(n)=n.
Why this matters: every later step plugs these three into the win-condition h(n)≤cf(n)−acf(n/b). If you misread a or b, every constant afterwards is wrong.
A friend claims: "I proved T(n)≤(c+2)n, so T(n)=O(n)." Is the conclusionO(n) automatically justified? Answer yes/no and give the one-line reason.
Recall Solution
No. Induction requires reproducing the same constant c you assumed. Ending at (c+2)n means each level adds 2n; over the logn levels this piles up to Θ(nlogn). A bound is only proven when the residual is ≤0 with a fixedc.
Prove T(n)=2T(n/2)+n=O(nlogn) by finding an explicit c that also works at the base case T(2)=3.
Recall Solution
Guess:T(n)≤cnlogn.
Assume (IH):T(n/2)≤c2nlog2n (valid since n/2<n).
Substitute:T(n)≤2(c2nlog2n)+n=cnlog2n+n.Massage with the log split:
=cn(logn−1)+n=cnlogn−cn+n=cnlogn−(c−1)n.Absorb: need −(c−1)n≤0⇒c≥1.
Base case at n0=2: need T(2)=3≤c⋅2log2=2c. So c≥1.5.
Combine: both conditions met by c=1.5 (rounded up: any c≥1.5). ✓
Guess:T(n)≤clogn.
Assume:T(n/2)≤clog2n=c(logn−1).
Substitute:T(n)≤c(logn−1)+1=clogn−c+1.Absorb: residual −c+1≤0⇒c≥1.
Base case at n0=2: T(2) constant ≤clog2=c; choose c≥max(1,T(2)). ✓
Result: T(n)=O(logn) — the classic binary-search recurrence.
Show the guess T(n)=2T(n/2)+n=O(n)fails, and name the true tight bound.
Recall Solution
Guess:T(n)≤cn.
Substitute:T(n)≤2(c2n)+n=cn+n=(c+1)n.
The residual is +n>0 — positive, and no choice of c makes +n≤0.
The bound we reproduce is (c+1)n, not cn. Guess fails.
True tight bound: Θ(nlogn) (proven in Exercise 2.1).
The recurrence T(n)=T(n/2)+T(n/4)+n. Test the guess T(n)≤cn and report the smallest c that works.
Recall Solution
Substitute:T(n)≤c2n+c4n+n=43cn+n.Absorb: need 43cn+n≤cn, i.e. n≤41cn, i.e. c≥4.
So c=4 works (residual 43⋅4n+n=3n+n=4n=cn exactly). ✓
Result: T(n)=O(n) with c=4.
Contrast with 3.1: here the coefficients 21+41=43<1 leave shrinking room, so a plain constant absorbs the +n. In 3.1 the coefficient was 2⋅21=1, no room, so it failed.
T(n)=4T(n/2)+n. A student guesses O(n2). Verify and find the smallest valid c (base case T(1)=1).
Recall Solution
Guess:T(n)≤cn2.
Substitute:T(n)≤4(c(2n)2)+n=4c⋅4n2+n=cn2+n.Absorb: residual +n>0 — plain O(n2)reproducescn2+n, notcn2. Fails as-is!
Fix (strengthen): guess T(n)≤cn2−dn (subtract lower-order term).
Substitute the stronger guess:T(n)≤4(c4n2−d2n)+n=cn2−2dn+n=cn2−(2d−1)n.Absorb: need −(2d−1)n≤−dn, i.e. (2d−1)≥d, i.e. d≥1.
Pick d=1. Base casen0=1: T(1)=1≤c⋅1−1⋅1=c−1⇒c≥2.
Pick c=2,d=1: T(n)≤2n2−n for n≥1, so T(n)=O(n2). ✓
The figure contrasts two residuals: a draining one (dips below zero — bound survives) and a stubborn one (stays positive — guess fails until strengthened).
Prove T(n)=2T(n)+logn=O(logn⋅loglogn) using a change of variables.
Recall Solution
Why change variables? The n argument is ugly for induction (it doesn't shrink linearly). Substitute m=logn (so n=2m, and n=2m/2). Let S(m)=T(2m)=T(n).
Then T(n)=T(2m/2)=S(m/2) and logn=m:
S(m)=2S(m/2)+m.
This is exactly the Exercise 2.1 recurrence! By that result:
S(m)=O(mlogm).Change back:m=logn, so
T(n)=S(m)=O(mlogm)=O(logn⋅loglogn).✓
The trick: convert a multiplicative shrink (n) into an additive halving via logs, then reuse a known result.
Prove T(n)=2T(n/2)+n2=O(n2), carefully, with an explicit c for base case T(1)=1.
Recall Solution
Guess:T(n)≤cn2.
Substitute:T(n)≤2(c(2n)2)+n2=2c⋅4n2+n2=2cn2+n2.Absorb: need 2cn2+n2≤cn2, i.e. n2≤2cn2, i.e. c≥2.
Base casen0=1: T(1)=1≤c⋅1⇒c≥1.
Combine:c=2 satisfies both. So T(n)≤2n2, T(n)=O(n2). ✓
Note: here h(n)=n2dominates the recursion cost, so the answer is Θ(n2) — compare against Master Theorem Case 3.
No guess is given. For T(n)=3T(n/2)+n, invent the tight Θ bound and prove the O direction from scratch, giving explicit c,d if strengthening is needed (T(1)=1).
Recall Solution
Getting the guess (use Recursion Tree Method mentally): work per level multiplies by 3 but problem size halves, so cost per level =3i⋅(n/2i)=n(3/2)i, growing geometrically → dominated by the leaves. Leaves: 3log2n=nlog23. So guess T(n)=Θ(nlog23), and log23≈1.585.
Prove O(nlog23). Let α=log23, so 3=2α and 3(n/2)α=3⋅nα/2α=3nα/3=nα.
Plain guessT(n)≤cnα:
T(n)≤3c(n/2)α+n=cnα+n.
Residual +n>0 — fails. Strengthen:T(n)≤cnα−dn.
T(n)≤3(c(n/2)α−d2n)+n=cnα−23dn+n=cnα−(23d−1)n.Absorb: need −(23d−1)n≤−dn, i.e. 23d−1≥d, i.e. 2d≥1, i.e. d≥2.
Pick d=2. Base casen0=1: T(1)=1≤c⋅1−2⋅1=c−2⇒c≥3.
Pick c=3,d=2: T(n)≤3nα−2n with α=log23. So T(n)=O(nlog23). ✓
Prove the lower boundT(n)=2T(n/2)+n=Ω(nlogn) (the Ω direction; base T(2)=1).
Recall Solution
Why a separate proof?O bounds from above (≤); Ω bounds from below (≥). Together they give Θ. The inequality direction flips, so the absorb condition flips too.
Guess:T(n)≥cnlogn (want c>0).
Assume:T(n/2)≥c2nlog2n.
Substitute:T(n)≥2(c2nlog2n)+n=cn(logn−1)+n=cnlogn−(c−1)n.Absorb (flipped): need −(c−1)n≥0, i.e. c≤1.
Base casen0=2: T(2)=1≥c⋅2log2=2c⇒c≤0.5.
Combine: pick c=0.5 (satisfies c≤1 and c≤0.5). So T(n)≥0.5nlogn, T(n)=Ω(nlogn). ✓
Together with Exercise 2.1: T(n)=Θ(nlogn).