A recursion tree is the master theorem's proof, drawn
Sum the work at each level and add up the levels. It applies to uneven splits, where the theorem does not.
A recursion tree solves recurrences the master theorem cannot. Amortised analysis answers a different question: what a sequence of operations costs on average, when one of them is occasionally expensive.
Core ideas
One technique for recurrences the theorem misses, and one for the case where the worst case is a bad summary.
Sum the work at each level and add up the levels. It applies to uneven splits, where the theorem does not.
Not a single operation. Occasional expensive operations are paid for by many cheap ones.
It is a worst-case guarantee over any sequence, with no probability. Averaging over random inputs is a different claim.
The material
Recursion trees for awkward recurrences, amortisation for uneven costs.
Draw the recursion as a tree: the root does the top-level combining work, its children are the subproblems, and so on to the base cases. The total cost is the sum of the work at every node, which is best computed level by level.
T(n) = T(n/3) + T(2n/3) + n. Each level does n units of combining work, because the subproblem sizes at each level still sum to n. The deepest branch shrinks by 2/3 each time, so the depth is log_{3/2} n. Total: Θ(n log n) — the same as an even split.
That is why quicksort survives an imperfect pivot. Any constant-fraction split gives logarithmic depth, and only a consistently extreme pivot — splitting off one element at a time — produces the quadratic worst case.
T(n) = 2T(n/2) + n². Level i has 2ⁱ subproblems of size n/2ⁱ, doing 2ⁱ(n/2ⁱ)² = n²/2ⁱ work. The total is n² Σ 1/2ⁱ < 2n², so T(n) = Θ(n²): the root dominates, and the master theorem agrees since log₂2 = 1 < 2 = d.
The amortised cost of an operation is the total cost of a worst-case sequence of m operations, divided by m. It is a guarantee about sequences, not about any single operation.
A dynamic array that doubles its capacity when full, copying all elements, supports insertion in Θ(1) amortised time, even though a single insertion can cost Θ(n).
Consider n insertions starting from capacity 1. The copies happen when the size reaches 1, 2, 4, 8, …, costing 1 + 2 + 4 + ⋯ + 2^{⌊log₂ n⌋} < 2n element moves in total.
Adding the n insertions themselves, the total is under 3n, so the amortised cost per insertion is under 3 — a constant.
□
The geometric series is doing the work: the expensive operations are rare and their cost grows exactly as fast as the gaps between them, so the total telescopes. The geometric sum of “Induction with Sums and Products”, in Induction and Recursion, is the calculation.
Doubling is essential. Growing by a fixed amount c instead means copies at sizes c, 2c, 3c, …, totalling Θ(n²) moves — an amortised cost of Θ(n) per insertion. The two policies differ by a whole class.
The accounting method applied to the doubling array: charge 3 units per insertion — one to insert, one saved to copy this element later, one saved to copy an older element. When the array doubles, every element has exactly the credit needed for its move.
Amortised is not average-case. Average-case analysis assumes a distribution over inputs and computes an expectation. Amortised analysis assumes nothing and bounds the total for any sequence, which is a strictly stronger guarantee.
Interactive
Counts from running, not from quoting
Method
Tree for a recurrence, amortisation for a sequence.
Uneven splits, varying subproblem sizes, or a forcing term between the cases.
Then sum over levels. The depth is set by the branch that shrinks slowest.
Not the worst single operation. A geometric series usually appears.
Amortised bounds hold for any sequence; average-case bounds need a distribution. They are different claims.
Inserting 16 elements, starting from capacity 1.
The last two lines are the point. Doubling and incrementing look like minor implementation choices and differ by a whole complexity class. Every dynamic array in every standard library doubles for this reason.
The "< 2n" above is a fact about n = 16, a power of two, where the last doubling is well past. One insert later, at n = 17, the array doubles again: 31 copies, total 48, amortised 2.82 — above 2 and still below the 3 the proof guarantees for every n. That is why the theorem is stated with 3.
Show that a dynamic array growing by a factor of 1.5 still has amortised Θ(1) insertion, and identify the ratio of the series. Any constant factor above 1 works, and that is the theorem.
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.