Sub topic 10
Case 3: When the Root Dominates, and the Regularity Condition
This chapter assumes you can read Big-Omega and Big-Theta notation and sum a geometric series. It also assumes you have met the master theorem's setup from earlier chapters: the recurrence T(n) = aT(n/b) + f(n) and the critical exponent log_b a. Cases 1 and 2 covered recurrences where the leaves carry most of the work, or where every level carries about the same amount. Case 3 covers the remaining situation, where the work at the top of the recursion tree outweighs everything below it.
The Statement
Let a ≥ 1 and b > 1. Case 3 has two conditions, and both must hold:
- Growth condition. f(n) = Ω(n^(logb a + ε)) for some constant ε > 0. In words, f(n) grows polynomially faster than n^(logb a).
- Regularity condition. There is a constant c < 1 such that a·f(n/b) ≤ c·f(n) for all sufficiently large n.
When both hold, T(n) = Θ(f(n)).
The result says that the non-recursive work at the root sets the running time. The recursive calls add at most a constant factor.
Why the Root Dominates
Look at the recursion tree level by level. Level j has a^j nodes, and each one does f(n/b^j) work, so level j costs a^j·f(n/b^j).
The regularity condition says that going down one level multiplies the per-level cost by at most c. Apply it j times:
a^j·f(n/b^j) ≤ c^j·f(n)
So the level costs are bounded by a decreasing geometric series. Summing over all internal levels:
Σ c^j·f(n) ≤ f(n) / (1 − c)
The leaves add Θ(n^(log_b a)), and the growth condition makes that o(f(n)). The root alone costs f(n), so T(n) = Ω(f(n)). Putting the two bounds together gives T(n) = Θ(f(n)), and the hidden constant is at most about 1/(1 − c).
This argument uses regularity, not growth, to make the level sums shrink. The growth condition only makes sure the leaves cannot overtake the root.
Worked Example 1: T(n) = 2T(n/2) + n²
- a = 2, b = 2, f(n) = n², and log_2 2 = 1.
- Growth: n² = Ω(n^(1+ε)) with ε = 1. This holds.
- Regularity: 2·(n/2)² = n²/2, so the condition holds with c = 1/2.
The answer is T(n) = Θ(n²). If you unroll it with T(1) = 1 for n a power of 2, you get exactly T(n) = 2n² − n. The leading constant 2 equals 1/(1 − c), which matches the geometric bound.
Worked Example 2: T(n) = 3T(n/4) + n log n
- a = 3, b = 4, f(n) = n log n, and log_4 3 ≈ 0.793.
- Growth: n log n ≥ n = n^(0.793 + 0.207), so ε ≈ 0.2 works.
- Regularity: 3·(n/4)·log(n/4) ≤ (3/4)·n log n, because log(n/4) < log n. So c = 3/4.
The answer is T(n) = Θ(n log n). The log factor does not get in the way here. The polynomial gap between n and n^0.793 is large enough to absorb it.
Polynomials Pass Regularity Automatically
For f(n) = n^d:
a·(n/b)^d = (a / b^d)·n^d
The ratio a/b^d is below 1 exactly when b^d > a, which means d > logb a. That is the growth condition. So for a pure polynomial, the growth condition implies the regularity condition with c = a/b^d. The same is true for n^d·(log n)^k with k ≥ 0, which is why the `mastertheorem` helper from the statement chapter never has to check regularity separately.
When Regularity Fails
Regularity can fail when f(n) is not monotone and oscillates. A standard example:
T(n) = T(n/2) + n(2 − cos n)
Here a = 1 and b = 2, so log_b a = 0. Because n ≤ f(n) ≤ 3n, the growth condition holds with ε = 1. Now pick n = 2πk with k odd. Then cos n = 1, so f(n) = n. Also cos(n/2) = cos(πk) = −1, so f(n/2) = 3n/2. That gives a·f(n/b) = 1.5·f(n), and no c < 1 works. Since such n exist at every scale, the condition fails for arbitrarily large n.
The master theorem does not apply here. A direct bound still works: T(n) ≤ Σ 3n/2^j ≤ 6n and T(n) ≥ n, so T(n) = Θ(n). The theorem stops giving an answer, but the true answer may still be Θ(f(n)). In that situation you fall back to a recursion tree, the substitution method, or Akra-Bazzi.
Checking Numerically
The script below samples the ratio a·f(n/b)/f(n). A ratio that stays below some c < 1 is consistent with regularity, and a ratio of 1 or more at large n refutes it. Sampling can only refute regularity. It cannot prove it.
import math
def regularity_ratio(a, b, f, ns):
"""Largest observed value of a*f(n/b)/f(n) over the sample points ns."""
return max(a * f(n / b) / f(n) for n in ns)
def T(n, a, b, f):
"""Evaluate T(n) = a*T(n/b) + f(n) with T(1) = 1, for n a power of b."""
return 1 if n <= 1 else a * T(n // b, a, b, f) + f(n)
powers_of_two = [2 ** p for p in range(4, 31)]
print(regularity_ratio(2, 2, lambda n: n ** 2, powers_of_two)) # 0.5
print(regularity_ratio(3, 4, lambda n: n * math.log2(n), powers_of_two)) # 0.7, below 0.75
wobbly = lambda n: n * (2 - math.cos(n))
odd_multiples = [2 * math.pi * k for k in range(1, 2000, 2)]
print(round(regularity_ratio(1, 2, wobbly, odd_multiples), 4)) # 1.5: regularity fails
for p in range(4, 21, 4):
n = 2 ** p
t = T(n, 2, 2, lambda m: m ** 2)
print(n, t, round(t / n ** 2, 4)) # ratio approaches 2 = 1/(1 - c)The last loop prints T(n)/n² for the first worked example. The value climbs toward 2, the 1/(1 − c) constant from the proof.
Near Misses
Not every f(n) that is larger than n^(logb a) qualifies. Take T(n) = 2T(n/2) + n log n. Here logb a = 1 and f(n) = n log n is asymptotically larger than n. However, n log n is not Ω(n^(1+ε)) for any ε > 0, because log n grows slower than every n^ε. The growth condition fails, so case 3 does not apply. This recurrence belongs to extended case 2, covered in the next chapter.
Common Errors
| Error | Correction |
|---|---|
| Checking growth and skipping regularity | Write down an explicit c < 1 |
| Treating n log n as polynomially larger than n | A log factor is never a polynomial gap ε > 0 |
| Picking c = 1 | Regularity needs c strictly less than 1 |
| Concluding "no answer" when regularity fails | The theorem is silent, so solve another way |
| Answering Θ(n^(log_b a)) out of habit | In case 3 the answer is Θ(f(n)) |
Exercise
Solve T(n) = 4T(n/2) + n^3. Give ε and c.
Show answer
log_2 4 = 2 and f(n) = n^3 = Ω(n^(2+ε)) with ε = 1. Regularity: 4(n/2)^3 = n^3/2, so c = 1/2. By case 3, T(n) = Θ(n^3).
Exercise
Solve T(n) = 2T(n/2) + n^2 log n, and check regularity explicitly.
Show answer
log_2 2 = 1 and n^2 log n = Ω(n^(1+ε)) with ε = 1. Regularity: 2(n/2)^2 log(n/2) = (n^2/2)(log n − 1) ≤ (1/2) n^2 log n, so c = 1/2. T(n) = Θ(n^2 log n).
Exercise
Explain why T(n) = 2T(n/2) + n log n is not a case 3 recurrence, even though f(n) grows faster than n^(log_b a).
Show answer
Case 3 needs f(n) = Ω(n^(1+ε)) for some ε > 0. n log n / n^(1+ε) = log n / n^ε tends to 0 for every ε > 0, so the growth condition fails. The recurrence falls under extended case 2 and solves to Θ(n log^2 n).
Exercise
For f(n) = n^d, show that the regularity constant is c = a/b^d, and explain why c < 1 exactly when the growth condition holds.
Show answer
a f(n/b) = a (n/b)^d = (a/b^d) n^d = (a/b^d) f(n), so c = a/b^d. Then c < 1 iff b^d > a iff d > logb a, which is the growth condition with ε = d − logb a.