Many divide-and-conquer algorithms have running times described by recurrences of the form
T(n)=aT(bn)+f(n)
where a≥1 is the number of subproblems, b>1 is the factor by which the problem size shrinks, and f(n) accounts for the work of dividing and combining. We interpret n/b as ⌊n/b⌋ or ⌈n/b⌉; the asymptotic bounds are the same.
The Critical Exponent
The key quantity is the critical exponent
ccrit=logba
This is the exponent of n in the time contributed by the leaf level of the recursion tree. The Master Theorem compares f(n) (the work done at the root and internal levels) against nccrit (the work done at the leaves).
The Three Cases
Case 1: Leaf-Dominated
If f(n)=O(nccrit−ε) for some constant ε>0, then
T(n)=Θ(nccrit)
The leaves dominate: the cost at the bottom of the tree outweighs everything above. Note the ε: f(n) must be polynomially smaller than nccrit, not just asymptotically smaller.
Example: T(n)=9T(n/3)+n
a=9, b=3, ccrit=log39=2. Here f(n)=n=O(n2−0.5), so Case 1 gives T(n)=Θ(n2). The 9 subproblems at size n/3 generate Θ(n2) leaf work, overwhelming the linear f(n).
Case 2: Balanced
If f(n)=Θ(nccrit), then
T(n)=Θ(nccritlgn)
Each level of the recursion tree contributes the same amount of work (Θ(nccrit)), and there are logbn levels, giving the extra lgn factor.
Example: T(n)=2T(n/2)+Θ(n) (Mergesort)
a=2, b=2, ccrit=1. f(n)=Θ(n)=Θ(n1), so Case 2: T(n)=Θ(nlgn).
Case 3: Root-Dominated
If f(n)=Ω(nccrit+ε) for some ε>0, and the regularity condition af(n/b)≤cf(n) holds for some constant c<1 and all sufficiently large n, then
T(n)=Θ(f(n))
The root dominates: the top-level work outweighs everything below. The regularity condition ensures the work decreases geometrically down the tree: each level’s work is at most a constant fraction of the level above.
Example: T(n)=3T(n/4)+nlgn
a=3, b=4, ccrit=log43≈0.793. f(n)=nlgn=Ω(n0.793+0.2). Check regularity: 3⋅(n/4)lg(n/4)=43nlgn−43nlg4≤43nlgn. With c=3/4<1, regularity holds. Case 3: T(n)=Θ(nlgn).
The Regularity Condition (Case 3)
The regularity condition af(n/b)≤cf(n) for c<1 is not a formality. Without it, Case 3 can fail even when f(n)=Ω(nccrit+ε). It rules out oscillating functions where the total cost at a child level could exceed the parent level. Most polynomially bounded functions encountered in practice satisfy it automatically.
The Polynomial Gap (ε)
The ε>0 in Cases 1 and 3 means the Master Theorem requires a polynomial separation between f(n) and nccrit. A logarithmic gap is not enough.
Example Where the Master Theorem Fails
T(n)=2T(2n)+nlgn
a=2, b=2, ccrit=1. f(n)=nlgn grows faster than n but the ratio f(n)/n=lgn is not polynomial in nε for any ε>0. So f(n)∈/Ω(n1+ε), and f(n)∈/O(n1−ε). The Master Theorem cannot resolve this recurrence. We must use the substitution method or the recursion-tree method instead.
This gap between Cases 2 and 3 (or between Cases 1 and 2) arises fairly rarely in practice for standard algorithmic recurrences.
The Recursion-Tree Method
When the Master Theorem cannot be applied, the recursion tree provides a fallback: expand the recurrence level by level and sum the work.
For T(n)=2T(n/2)+nlgn:
| Level | Number of nodes | Problem size | Work per node | Work per level |
|---|
| 0 | 1 | n | nlgn | nlgn |
| 1 | 2 | n/2 | (n/2)lg(n/2) | nlg(n/2) |
| 2 | 4 | n/4 | (n/4)lg(n/4) | nlg(n/4) |
| ⋮ | ⋮ | ⋮ | ⋮ | ⋮ |
| k | 2k | n/2k | (n/2k)lg(n/2k) | nlg(n/2k) |
Total work: ∑k=0lgn−1nlg(n/2k)=n∑k=0lgn−1(lgn−k). This is n times an arithmetic series summing to Θ(lg2n), so T(n)=Θ(nlg2n).
Worked Examples
Example 1: Binary Search
T(n)=T(n/2)+Θ(1)
a=1, b=2, ccrit=log21=0. f(n)=Θ(1)=Θ(n0), so Case 2: T(n)=Θ(lgn).
Example 2: Strassen’s Matrix Multiplication
T(n)=7T(n/2)+Θ(n2)
a=7, b=2, ccrit=log27≈2.807. f(n)=Θ(n2)=O(n2.807−0.5), so Case 1: T(n)=Θ(nlg7)≈Θ(n2.807).
Example 3: T(n)=2T(n/2)+Θ(n3)
a=2, b=2, ccrit=1. f(n)=Θ(n3)=Ω(n1+1). Regularity: 2⋅(n/2)3=41n3≤c⋅n3 for c=1/4. Case 3: T(n)=Θ(n3).
Example 4: T(n)=3T(n/2)+n2
a=3, b=2, ccrit=log23≈1.585. f(n)=n2=Ω(n1.585+0.3). Regularity: 3(n/2)2=43n2≤43n2. Case 3: T(n)=Θ(n2).
Example 5: T(n)=8T(n/2)+Θ(n2)
a=8, b=2, ccrit=log28=3. f(n)=Θ(n2)=O(n3−0.5), Case 1: T(n)=Θ(n3).
Systematic Approach to Applying the Theorem
- Identify a, b, and f(n) from the recurrence.
- Compute ccrit=logba.
- Compare f(n) against nccrit.
- If f(n) is polynomially smaller → Case 1, result Θ(nccrit).
- If f(n) is asymptotically equal → Case 2, result Θ(nccritlgn).
- If f(n) is polynomially larger → check regularity; if satisfied, Case 3, result Θ(f(n)).
- If none of the above applies (the gap case) → use the recursion tree or substitution method.
Summary
| Case | Condition | Solution | Intuition |
|---|
| 1 | f(n)=O(nccrit−ε) | Θ(nccrit) | Leaves dominate |
| 2 | f(n)=Θ(nccrit) | Θ(nccritlgn) | All levels equal |
| 3 | f(n)=Ω(nccrit+ε) and regularity holds | Θ(f(n)) | Root dominates |
| Gap | f(n)/nccrit is polylogarithmic | Not applicable | Use tree method |
| Example recurrence | a,b | ccrit | f(n) | Case | Result |
|---|
| T(n)=2T(n/2)+n | 2,2 | 1 | n | 2 | Θ(nlgn) |
| T(n)=9T(n/3)+n | 9,3 | 2 | n | 1 | Θ(n2) |
| T(n)=T(2n/3)+1 | 1,1.5 | 0 | 1 | 2 | Θ(lgn) |
| T(n)=3T(n/4)+nlgn | 3,4 | ≈0.793 | nlgn | 3 | Θ(nlgn) |
| T(n)=2T(n/2)+nlgn | 2,2 | 1 | nlgn | Gap | Θ(nlg2n) |