3.1.9 · D1Complexity Analysis

Foundations — Recursion tree method

2,157 words10 min readBack to topic

Before you can read the parent note, you need to own every letter it throws at you. This page builds each one from nothing: plain words → a picture → why the topic can't live without it. Read top to bottom; each item leans on the one above.


1. — the size of the problem

Why the topic needs it: every recursion tree question is "how does the work scale as ?" Without a name for input size, there is nothing to scale.


2. — a function, i.e. a work-meter

Common meters you'll meet:

  • → work grows in a straight line (do one thing per box).
  • → work grows like the area of an square.
  • → constant work, ignores size.

Why the topic needs it: the value written inside every tree node is . is what you sum.


3. — the total runtime we're hunting

Why the topic needs it: the entire method exists to compute . Everything else is bookkeeping toward this number.


4. A recurrence — an equation that mentions itself

Read it in plain English: "The work on size equals the work of smaller jobs of size , plus for the splitting/combining I do myself."

Why the topic needs it: a recursion tree is literally the picture of one recurrence being unrolled.


5. — the branching factor

Why the topic needs it: controls width — how many nodes sit at each depth, hence how many meters you sum per row.


6. — the shrink factor

Why the topic needs it: controls depth — how fast the size falls to decides how many rows the tree has.


7. Exponents and powers: , ,

Two powers do all the heavy lifting:

  • = number of nodes at depth (each of the nodes above made more).
  • = total shrink after levels, so size at depth is .

We also write (e.g. for , for ). The exponent is the "degree" of the per-call work.

Why the topic needs it: the whole verdict hinges on comparing the growth against the shrink inside the meter.


8. The logarithm:

Two facts you'll reuse:

  • grows very slowly — doubling adds only a constant to it.
  • All bases differ by a constant: and are the same up to a fixed multiplier, which is why unbalanced trees still land at .

Why the topic needs it: depth = is one of the three knobs (DWW). See Binary Search for the simplest place a appears in code.


9. — the leaf count

Why the topic needs it: one of the three outcomes is "leaves win", and its size is exactly .


10. Geometric series — summing the level costs

Why the topic needs it: deciding "who dominates" is asking which way the geometric series tips.


11. Big-O family: , ,

Why the topic needs it: the recursion tree's output is always stated as ; constants get dropped because the tree only reveals shape, not exact tallies. Full treatment in Big-O Notation.


How the foundations feed the topic

n input size

recurrence T of n

f of n per-call work

a branching factor

b shrink factor

recursion tree

width a to the i

depth log base b of n

level work a to i times f

geometric series ratio a over b to d

Theta answer via Big-O

Read it as: the four ingredients () assemble the recurrence; the recurrence unfolds into the tree; width and depth come from and ; the level-work forms a geometric series; the series verdict, expressed in Big-O, is the answer.


Equipment checklist

Self-test: can you answer each without peeking?

What does mean and what picture goes with it?
Input size — a row of boxes to process.
What is the difference between and ?
is the work of one call by itself; is the total of that call plus all recursive calls it triggers.
In , what do and each control?
controls width (children per node); controls depth (how fast size shrinks).
Why is the tree depth and not something else?
Because size at level is ; setting it to gives , and only a log pulls out of the exponent.
How many nodes and how many leaves does the tree have at depth and at the bottom?
nodes at depth ; leaves at the bottom.
What is the ratio of a recursion tree's geometric series, and what do mean?
; root dominates, equal levels (extra ), leaves dominate.
Why do we state the final answer with instead of exact numbers?
The tree reveals growth shape, not exact constants, so captures the true growth rate while ignoring constant factors.

Connections