Visual walkthrough — Recursion tree method
Step 1 — What a recurrence secretly means
WHAT. A recurrence is a rule that defines the running time of a program in terms of itself. Our star example is
Let's name every piece before we use it:
- ::: the total time to solve a problem of size (this is the thing we want to find).
- ::: the size of the input — how many items, how big the list is.
- ::: the branching factor — how many smaller problems this call creates. Always .
- ::: the shrink factor — each smaller problem is the size. Always (so problems really do get smaller).
- ::: the local cost — the work this call does by itself, NOT counting the recursive calls it makes (splitting, combining, one comparison — whatever the algorithm does at this level).
- ::: the base case from the definition box — a size- problem costs a fixed constant. We write it right into the recurrence so the tree knows where to stop and what the bottom costs.
WHY. The formula is self-referential: to compute you need , which needs … forever. That circular definition is useless until we unfold it. The tree is the unfolding — and the base case tells the unfolding when to halt.
PICTURE. One call = one box. It does work itself (orange), then hands off copies of a problem of size to children below.

Step 2 — Grow the tree one level down
WHAT. Replace each by its own recurrence. A size- call does work itself and spawns children of size .
Annotating the growing sum:
- ::: the root's own work (level ).
- ::: children, each doing work (level ).
- ::: the leftover un-unfolded lump — grandchildren each of size (level , not expanded yet).
WHY. Every time we substitute, one more fully-known level (-terms) peels off and the unknown retreats one level deeper. If we keep going until sizes reach , the remaining becomes (the base case) and the whole tree turns into pure known costs — no more mystery .
PICTURE. Two full levels drawn. Count the boxes per row: , then . Watch the size labels shrink: .

Step 3 — The width of level
WHAT. How many boxes sit at depth ?
- ::: the level index — a counter for which row we're on. is the root, its children, and so on downward. (This is the very symbol the summation later will run over.)
- ::: multiply the branching by itself times. Level has node; level has ; level has .
WHY. Each box makes exactly children. Multiplying the count by once per level is the definition of raising to a power. That is why an exponential — not — appears: repeated multiplication, never repeated addition.
PICTURE. The row counts light up as powers of (here : ). The tree fans out.

Step 4 — The size at level , and how deep it goes
WHAT. A box at level has size and the tree ends when that size hits the base case .
- ::: divide by once per level, times over → .
- Stop when — that's exactly the base-case size from Step 1.
Solve for the stopping level:
- ::: "how many times must I divide by to reach ?" That is literally the definition of a logarithm — the inverse of exponentiation. We use here (not, say, ) precisely because we're repeatedly dividing, and division-by--until-1 is what counts. In this whole page, "" always means "the number of levels the tree has."
So the tree has levels, indexed .
WHY. Depth is not controlled by how many children you make () — it's controlled by how fast the size shrinks (). Fast shrink ⇒ shallow tree; slow shrink ⇒ deep tree.
PICTURE. A vertical ruler on the left showing size collapsing and the height marked.

Step 5 — Work done by a whole level
WHAT. Multiply how many boxes (Step 3) by how much each costs (Step 4's size fed into ):
- ::: number of boxes on level (Step 3).
- ::: the local cost each of those boxes pays, because each has size (Step 4).
- ::: the total work of that entire row.
WHY. Total effort of a row = (people in the row) × (effort each). Same as counting money: coins × value-per-coin. We add rows, not individual boxes, because rows are the natural bookkeeping unit.
PICTURE. One highlighted row; a bracket labels the row total .

Step 6 — Add all the rows: the master formula appears
WHAT. Now — and only now, with , , and the base case all defined — we write the total. It is the sum of every row's work (Step 5), from the top () to the leaves ():
- ::: "" means add up; the index (defined in Step 3) runs from the root row down to the last row (defined in Step 4).
- the summand ::: the row total from Step 5.
The very bottom row (the leaves) has boxes. A useful identity rewrites that in terms of :
WHY this identity is true (change of base + exponent rules, step by step). Take logs base of both sides — a valid move because is a one-to-one function, so two numbers are equal exactly when their logs are.
- Left side: , using the power rule (a power inside a log comes out front as a multiplier).
- Right side: , by the same rule.
- Both sides equal the same product — multiplication doesn't care about order — so the originals are equal.
Now the leaf cost:
- Each leaf is a size- base case, so it costs — the fixed constant we pinned down in the opening definition box. (This is the assumption made explicit: without a stated base-case cost the leaves would have no value to sum.)
- Total leaf cost (number of leaves) (cost each) .
Nothing is guessed — we gathered every box, grouped by row, summed, and folded the base case into the bottom row. This is the parent note's boxed result, now earned.
PICTURE. The full tree with a running total on the right stacking up each into the grand sum, and the leaf row labelled with its base-case cost.

Step 7 — Where does the sum concentrate? The three verdicts
WHAT. Suppose (the common case — is just the exponent of the polynomial cost). Then a row's work is
- ::: the root's cost, pulled out front (it doesn't depend on ).
- ::: the ratio between one row's total and the row above it. Each step down multiplies the row work by . This is a geometric series — a sum where each term is a fixed multiple of the last (see Geometric Series).
Now the whole answer depends only on whether is below, equal to, or above :
| Ratio | Rows go… | Who dominates | Answer |
|---|---|---|---|
| (i.e. ) | shrink downward | the root | |
| (i.e. ) | stay equal | every row equally | |
| (i.e. ) | grow downward | the leaves |
- : a decreasing geometric series sums to at most a constant times its first term → root wins.
- : every one of the rows costs → multiply → the factor.
- : an increasing geometric series is dominated by its last term (the leaves) → wins.
WHY. We use a geometric series (not arithmetic) because rows are related by multiplication by , exactly matching Step 3's "multiply by each level". The direction of is the single knob that decides everything — this is the Master Theorem, derived.
PICTURE. Three little bar charts side by side — bars shrinking, level, and growing down the rows — with the dominating region shaded.

Step 8 — Edge & degenerate cases (so nothing surprises you)
WHAT. Three boundary situations the smooth formula must still handle.
(a) — no branching (e.g. Binary Search, ). Every row has box. The tree is a single chain, not a fan. Row work is just , and depth is still . For binary search , so total . No leaf explosion, because the leaf count : a single base-case leaf costing .
(b) Sizes shrink at different rates — unbalanced tree (). There is no single . Instead we bound the tree between its shortest branch (divide by : depth ) and longest branch (multiply survivors by : depth ).
WHY each full level still sums to — the invariant, level by level. Give every node a label equal to its own size. The root's label is . When a node of size splits, its two children get labels and , which add back to — splitting preserves the parent's total. So the sum of all labels on any complete level equals the sum on the level above it, which by induction is always . Because is linear (), the work on a level equals the sum of its labels . This holds at every depth, not just the top — that's the whole point of the invariant. (Deep down, short branches finish early, so real levels sum to strictly less than , still .) With levels each : .
(c) not a clean power of . Then isn't a whole number and the last level is ragged. We simply round: depth is . Rounding changes the level count by at most , which is absorbed by . So the answer is unchanged — the formula is robust.
WHY. A derivation you can only apply to perfectly balanced, power-of- inputs would be useless in practice. Covering , unbalanced splits, and non-powers shows the method survives every real recurrence.
PICTURE. Three mini-trees: a straight chain (), a lopsided tree with short/long paths and the size-labels adding back to the parent marked, and a ragged last row for non-power .

The one-picture summary
Everything above, compressed: the tree, its three knobs (Depth, Width, Work), the row-sum, the base-case leaves, and the three verdicts driven by the ratio .

Recall Feynman: the whole walkthrough in plain words
A boss gets a job of size and does a little work himself — that's . Then he splits it into smaller jobs, each of size , and hands them down. Every helper does the same thing to their piece, until a job is size — the tiniest job, done directly for a fixed tiny cost (that's the base case, ). Draw this as a family tree of jobs.
To find the total effort, don't chase individual workers — add up one row at a time. A row at depth has workers (multiply by each step down), each holding a job of size , so the row's effort is .
How tall is the tree? Keep dividing by until you reach size — that takes steps, so that's the height. Now stack up all the row-efforts, including the bottom row of tiny base-case jobs. Whether the tree's work piles up at the top (boss does most), spreads out evenly, or crashes down to the bottom (a riot of tiny workers) depends on one number: . Smaller than → top wins (). Exactly → everyone shares, giving an extra . Bigger than → the swarm of leaves wins (). That single comparison is the whole Master Theorem, and you just drew it.
Connections
- 3.1.09 Recursion tree method (Hinglish) — the parent topic this walkthrough visualises.
- Master Theorem — Step 7's three verdicts are its three cases.
- Geometric Series — the sum tool that decides who dominates.
- Big-O Notation — the notation defined up top; how we bound each row and drop constants.
- Divide and Conquer — the algorithm family that produces .
- Merge Sort (), Binary Search () — the and pictures.
- Substitution Method — the guess-and-prove alternative the tree helps you set up.