The recursion tree explains the three cases
Level i has aⁱ subproblems of size n/bⁱ. Whether the work grows, shrinks or stays level down the tree is exactly the comparison.
Algorithms that split a problem into a pieces of size n/b produce recurrences of one shape. The master theorem settles them by comparing log_b a with the exponent in f(n).
Core ideas
The three cases are not arbitrary: they are which level of the recursion tree carries most of the work.
Level i has aⁱ subproblems of size n/bⁱ. Whether the work grows, shrinks or stays level down the tree is exactly the comparison.
a = 2, b = 2, d = 1, so log₂2 = 1 = d. Every level does Θ(n) work and there are log n levels.
Karatsuba multiplication does 3 multiplications of half-size instead of 4, and log₂3 ≈ 1.585 < 2 is the entire improvement.
The material
Where the recurrence comes from, what the tree looks like, and the statement.
A divide-and-conquer algorithm splits an input of size n into a subproblems of size n/b, solves each recursively, and spends f(n) combining. The running time therefore satisfies T(n) = aT(n/b) + f(n).
With f(n) = nᵈ, the work at level i is aⁱ(n/bⁱ)ᵈ = nᵈ(a/bᵈ)ⁱ — a geometric series in i with ratio a/bᵈ. Which end dominates depends entirely on whether that ratio is less than, equal to, or greater than 1, and a/bᵈ compared with 1 is log_b a compared with d. That is the whole theorem.
T(n) = Θ(g(n)) means T(n) is trapped between two positive constant multiples of g(n) for all large enough n: c₁ g(n) ≤ T(n) ≤ c₂ g(n) once n is past some threshold. It names a growth rate and discards the constants. “Big-O, Big-Omega and Big-Theta” in Algorithms and Complexity makes this precise and works with it; here it is only the shape of the answer the theorem reports.
Let T(n) = aT(n/b) + Θ(nᵈ) with a ≥ 1, b > 1, d ≥ 0. Then T(n) = Θ(nᵈ) if log_b a < d; T(n) = Θ(nᵈ log n) if log_b a = d; and T(n) = Θ(n^{log_b a}) if log_b a > d.
The cases are numbered here in the order of the comparison — less, equal, greater — so case 1 is the root dominating and case 3 the leaves, and the lab below and Algorithms and Complexity use the same numbering. Some texts number them the other way round. When there is any doubt, name a case by what dominates rather than by its number.
T(n) = 2T(n/2) + n: a = 2, b = 2, d = 1, log₂2 = 1 = d. Balanced case, so Θ(n log n). Every level does n units of merging and there are log₂ n levels.
T(n) = T(n/2) + 1: a = 1, b = 2, d = 0, log₂1 = 0 = d. Balanced again, so Θ(log n). One subproblem and constant work per level.
Multiplying two n-digit numbers by splitting into halves needs four half-size products naively: T(n) = 4T(n/2) + n, and log₂4 = 2 > 1, giving Θ(n²) — no better than the schoolbook method. Karatsuba's identity does it with three: T(n) = 3T(n/2) + n, and log₂3 ≈ 1.585, giving Θ(n^{1.585}). One fewer multiplication changes the exponent.
Two cautions. The theorem as stated covers f(n) = Θ(nᵈ); forcing terms like n log n fall between the cases and need the fuller version. And it says nothing about constants — an algorithm with a better exponent may lose on realistic inputs, which is why Karatsuba is used for large numbers and schoolbook multiplication for small ones.
Setting n = bᵏ and Sₖ = T(bᵏ) turns T(n) = aT(n/b) + nᵈ into Sₖ = aSₖ₋₁ + (bᵈ)ᵏ, an ordinary linear recurrence that “Solving Linear Recurrences” solves. The master theorem is that solution, read back.
Interactive
Counts from running, not from quoting
Method
Read off a, b, d, then compare.
a is the number of subproblems, b the shrink factor, d the exponent of the combining work. Reading a off as the shrink factor is the standard slip.
log₂ 2 = 1, log₂ 3 ≈ 1.585, log₂ 4 = 2, log₂ 8 = 3. These four cover most examples.
Less, equal, greater — root dominates, level, leaves dominate.
Does the work per level grow, stay constant or shrink? The answer should match the case you selected.
Same theorem, three different answers.
Case 3 is the one where the recursion is doing the damage: n³ work arises from n^{log₂8} leaves, not from the combining. Strassen attacks exactly that by reducing a from 8 to 7, and gains an exponent improvement that no faster combining step could have produced.
For T(n) = 3T(n/4) + n, compute the work at levels 0, 1 and 2 and say whether it is growing or shrinking. Then check that the master theorem gives the case your tree predicted.
Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.
No recommendations yet for this lesson.