Sub topic 8
Case 1: When the Leaves Dominate
This chapter assumes you know Big-O and Big-Theta notation, can identify a, b, and f(n) in T(n) = aT(n/b) + f(n), and know that the watershed function is n^(log_b a). Case 1 covers recurrences where f(n) is polynomially smaller than the watershed.
The Rule
If f(n) = O(n^(log_b a − ε)) for some constant ε > 0, then:
T(n) = Θ(n^(log_b a))
The non-recursive work f(n) has no effect on the answer. The running time equals the number of leaves in the recursion tree, up to a constant factor.
Why the Leaves Win
Take f(n) = c·n^d with d < log_b a. Level j of the recursion tree has a^j subproblems of size n/b^j, so the work at that level is:
a^j · c(n/b^j)^d = c·n^d · (a/b^d)^j
Because d < logb a, we have b^d < a, so the ratio r = a/b^d is greater than 1. The level sums form a geometric series that grows with depth. A growing geometric series is dominated by its last term, and the last level is the leaves: a^(logb n) = n^(log_b a) of them, each doing constant work.
Worked Examples
| Recurrence | a, b | n^(log_b a) | f(n) | Result |
|---|---|---|---|---|
| 3T(n/2) + n (Karatsuba) | 3, 2 | n^1.585 | n | Θ(n^1.585) |
| 8T(n/2) + n² (naive matrix multiply) | 8, 2 | n³ | n² | Θ(n³) |
| 7T(n/2) + n² (Strassen) | 7, 2 | n^2.807 | n² | Θ(n^2.807) |
| 4T(n/2) + n log n | 4, 2 | n² | n log n | Θ(n²) |
In the last row, n log n = O(n^1.5), so ε = 0.5 works. A log factor does not stop f(n) from being polynomially smaller, provided the polynomial exponents differ.
Checking It Numerically
For n = 2^p, Karatsuba's recurrence with T(1) = 1 solves exactly to T(n) = 3·n^(log2 3) − 2n. The ratio T(n)/n^(log2 3) should therefore approach 3:
import math
def T(n):
# Karatsuba's recurrence with T(1) = 1
return 1 if n <= 1 else 3 * T(n // 2) + n
c = math.log2(3)
for p in range(4, 21, 4):
n = 2 ** p
print(n, T(n), round(T(n) / n ** c, 4))The ratio settles near a constant and does not grow, which confirms Θ(n^(log2 3)). The f(n) = n term only appears in the lower-order −2n.
Common Errors
- Inverting log_b a. For 3T(n/2), the exponent is log₂ 3 ≈ 1.585. It is not log₃ 2.
- Reporting f(n) as the answer. In case 1 the answer is always the watershed n^(log_b a). It is never f(n).
- Forgetting ε must be a constant. ε cannot shrink as n grows. It has to be one fixed positive number.
Exercise
Solve T(n) = 9T(n/3) + n√n using the master theorem, and state the ε you used.
Show answer
a = 9 and b = 3, so n^(log_3 9) = n². f(n) = n^1.5 = O(n^(2 − 0.5)), so ε = 0.5 and case 1 gives T(n) = Θ(n²).
Exercise
Does case 1 apply to T(n) = 4T(n/2) + n²/log n? Explain.
Show answer
No. The watershed is n², and n²/log n is smaller than n² only by a log factor. It is not O(n^(2 − ε)) for any ε > 0, so case 1 fails. The basic master theorem leaves this recurrence in a gap.