Sub topic 8
Case 1: When the Leaves Dominate
This chapter assumes you know Big-O and Big-Theta notation, can sum a geometric series, and have met the recursion tree and the master theorem statement in earlier chapters. You will learn the condition for case 1, why it gives the answer it does, how to apply it to real algorithms, and the mistakes people often make with it.
The statement of case 1
Take a recurrence of the form T(n) = aT(n/b) + f(n), with a ≥ 1 and b > 1. Let c = log_b a be the critical exponent. Case 1 says:
- If f(n) = O(n^(c − ε)) for some constant ε > 0, then T(n) = Θ(n^c).
Put simply, the work outside the recursive calls grows polynomially slower than n^(log_b a). When that holds, the total running time is set only by the number of leaves in the recursion tree. The exact shape of f(n) drops out of the answer.
Two details matter:
- The condition on f(n) is an upper bound (Big-O), not Θ. Any f(n) that is small enough qualifies, including a constant.
- The gap must be polynomial. A constant ε > 0 has to fit between the exponent of f and c. Being "a bit smaller" is not enough, as you will see below.
Why the leaves win
The recursion tree has depth L = log_b n. Level j has a^j nodes, each working on a problem of size n/b^j. The bottom level has a^L leaves, and
a^(logb n) = n^(logb a) = n^c.
Each leaf costs Θ(1), so the leaves alone contribute Θ(n^c).
Now add up the internal levels when f(n) = n^d with d < c. Level j contributes
a^j · (n/b^j)^d = n^d · (a/b^d)^j.
Because d < log_b a, we have b^d < a, so the ratio r = a/b^d is greater than 1. Each level does r times more work than the level above it. That makes the level costs an increasing geometric series, and an increasing geometric series is within a constant factor of its last term:
n^d · Σ_{j=0}^{L−1} r^j = Θ(n^d · r^L) = Θ(n^d · a^L / b^(dL)) = Θ(n^d · n^c / n^d) = Θ(n^c).
So the internal levels add up to Θ(n^c), the same order as the leaves. The total is Θ(n^c). For a general f(n) = O(n^(c−ε)), the same sum with d = c − ε gives an upper bound of O(n^c), and the leaves give a lower bound of Ω(n^c). Together they give Θ(n^c).
A level-by-level table
For Karatsuba multiplication, T(n) = 3T(n/2) + Θ(n). Here a = 3, b = 2, f(n) = n, and c = log_2 3 ≈ 1.585.
| Level j | Nodes | Subproblem size | Work at level |
|---|---|---|---|
| 0 | 1 | n | n |
| 1 | 3 | n/2 | 1.5n |
| 2 | 9 | n/4 | 2.25n |
| j | 3^j | n/2^j | (1.5)^j · n |
| log_2 n (leaves) | n^1.585 | 1 | Θ(n^1.585) |
Since f(n) = n = O(n^(1.585 − 0.5)), case 1 applies with ε = 0.5, and T(n) = Θ(n^(log_2 3)).
Checking the bound numerically
The script below evaluates the recurrence exactly for powers of two and divides by n^(log_2 3). If case 1 is right, the ratio should settle to a constant.
import math
def T(n):
# Karatsuba-style recurrence with T(1) = 1 and f(n) = n
return 1 if n <= 1 else 3 * T(n // 2) + n
c = math.log2(3)
for p in range(2, 21, 3):
n = 2 ** p
print(n, T(n), round(T(n) / n ** c, 4))The ratio approaches 3. The exact solution is T(n) = 3n^(log_2 3) − 2n, and the −2n term from the internal levels is a lower-order term, which is what case 1 predicts. If the ratio had kept growing like log n, you would be looking at case 2.
Worked examples
- Naive recursive matrix multiplication: T(n) = 8T(n/2) + Θ(n²). Here c = log_2 8 = 3, and n² = O(n^(3−1)). Case 1 gives Θ(n³).
- Strassen's algorithm: T(n) = 7T(n/2) + Θ(n²). Here c = log2 7 ≈ 2.807, and n² = O(n^(2.807−0.8)). Case 1 gives Θ(n^(log2 7)). Cutting eight multiplications to seven changes the exponent, while the Θ(n²) addition work has no effect on the bound.
- Visiting every node of a balanced binary tree: T(n) = 2T(n/2) + Θ(1). Here c = 1, and 1 = O(n^(1−1)). Case 1 gives Θ(n), as expected for touching n nodes.
- T(n) = 4T(n/2) + n log n: c = 2, and n log n = O(n^1.5) because log n grows slower than any positive power of n. Case 1 gives Θ(n²). A log factor does not block case 1 as long as a polynomial gap remains.
Case 1 shows where to look for speedups. When the leaves dominate, reducing a (fewer subproblems) improves the exponent, while making the combine step faster does not change the asymptotic bound at all.
Common errors
Treating "smaller" as "polynomially smaller"
Take T(n) = 2T(n/2) + n / log n. Here c = 1 and f(n) = n/log n is o(n), so it looks like case 1. It is not: no ε > 0 makes n / log n = O(n^(1−ε)), because n^ε eventually beats log n. Summing the tree shows what actually happens. Level j does 2^j · (n/2^j) / log(n/2^j) = n / (log n − j) work. Summed over all levels, that is n times a harmonic series, so T(n) = Θ(n log log n), not Θ(n). This recurrence falls in the gap between case 1 and case 2.
Getting the critical exponent wrong
The exponent is logb a, the log of the number of subproblems with the shrink factor as the base. Writing loga b instead flips the comparison. For 3T(n/2) + n, log2 3 ≈ 1.585, while log3 2 ≈ 0.63 would wrongly put the recurrence in case 3.
Confusing subproblem count with the work per call
In 8T(n/2) + n², the 8 is a and the 2 is b. If code makes two recursive calls on halves and each call loops over its input twice, that is still a = 2. The extra loop adds to f(n), not to a.
Checking for a regularity condition
Case 1 has no regularity condition. Only case 3 needs one. The polynomial gap is the only requirement.
Ignoring a non-constant base case
The argument assumes each leaf costs Θ(1). If the recursion stops at size k with Θ(k²) work per leaf, for example, count it as n/k leaf subproblems and recompute. Constant-size cutoffs only change the constant factor.
Exercises
Exercise
Solve T(n) = 9T(n/3) + n^1.5 with the master theorem. Give ε explicitly.
Show answer
Here a = 9, b = 3, so c = log_3 9 = 2. Since f(n) = n^1.5 = O(n^(2 − 0.5)), case 1 applies with ε = 0.5, and T(n) = Θ(n²).
Exercise
A recursive algorithm splits its input into 5 parts of size n/4, recurses on each, and does Θ(n log² n) extra work. What is its running time?
Show answer
T(n) = 5T(n/4) + n log² n. c = log4 5 ≈ 1.161. Since n log² n = O(n^1.1), choosing ε ≈ 0.06 works, so case 1 gives T(n) = Θ(n^(log4 5)) ≈ Θ(n^1.161).
Exercise
Does case 1 apply to T(n) = 4T(n/2) + n² / log n? If not, what is the bound?
Show answer
No. c = 2, and n²/log n is not O(n^(2−ε)) for any ε > 0, so the polynomial gap is missing. Level j does 4^j · (n/2^j)² / log(n/2^j) = n² / (log n − j) work. Summing over all levels gives n² times a harmonic series, so T(n) = Θ(n² log log n).
Exercise
An algorithm satisfies T(n) = 7T(n/2) + Θ(n²). A colleague halves the cost of the combine step. Another removes one recursive call, giving 6T(n/2) + Θ(n²). Which change improves the asymptotic running time, and to what?
Show answer
Halving the combine cost changes only a constant inside Θ(n²) and has no effect on the bound, which stays Θ(n^(log2 7)) ≈ Θ(n^2.807). Removing a call gives c = log2 6 ≈ 2.585. Since n² is still polynomially smaller, case 1 gives Θ(n^(log_2 6)), which is an asymptotic improvement.