3.1.9 · D5Complexity Analysis

Question bank — Recursion tree method

2,334 words11 min readBack to topic

First: the notation these traps use

Every question below lives inside one master recurrence, so let us name each symbol once, in plain words, before it appears anywhere else.

Look at the figure: it labels all six symbols on a small tree so the words attach to a picture.

Figure — Recursion tree method

The figure below shows the level sums as a bar per level, so you can see whether they grow, stay flat, or shrink downward — the single distinction that decides every trap.

Figure — Recursion tree method

True or false — justify

Every level of a recursion tree costs the same as the root, so total work is .
False. Level costs , not . It only stays flat when exactly cancels the shrink in (as in Merge Sort); otherwise the level sums grow or shrink geometrically.
A recursion tree always has exactly leaves.
False. The number of leaves is . It equals only when ; for it is .
If per-level work is a decreasing geometric series, the total is dominated by the leaves.
False. Decreasing means the first term (the root) is largest, so the root dominates and . Leaves dominate only when the series increases downward.
The depth of the tree depends on the branching factor .
False. Depth is set by how fast the size shrinks, i.e. : solving gives . The factor controls the width ( nodes), not the number of levels.
For the answer is purely because there are levels.
False. It is levels times the per-level work . If a single level cost more or less, the answer would change even with the same depth.
Adding a constant number of levels (like counting from to inclusive) changes the asymptotic answer.
False. With the root at level , the last level is , so there are levels. Concretely for : that is levels vs — a factor , a constant. Since ignores constant multipliers, and are both .
Floors and ceilings on the subproblem size can change the asymptotic answer.
False (for these divide-and-conquer recurrences). Replacing by or shifts each size by less than , perturbing depth and per-level work by only constant factors, which absorbs. That is why we analyse the clean and still get the right order.
In an unbalanced recurrence, you must find the exact number of nodes to solve it.
False. You bound the per-level work and the height range instead. For , each level sums to and height is , giving without counting nodes.
If for , the per-level work is constant and the total gains a factor.
True. The per-level ratio is , so every level does the same work , and summing over levels gives .

Spot the error

"Level has nodes each of size , so its work is for any ."
Wrong — that assumes is linear. The general level work is ; you substitute the size into . Only when does it simplify to .
"The ratio deciding the three cases is ."
Wrong — for the ratio is , not . The exponent from must appear; ignoring it misclassifies cases like (, not ).
"Since merge sort has leaves and work per level, its total is ."
Wrong — you don't multiply leaves by per-level work. You sum per-level work over all levels: . Leaf count is one level's contribution, not a multiplier.
"For I'll use because that's the first fraction."
Wrong — the branches shrink at different rates, so there is no single . The longest (slowest) branch sets the depth , and you bound per-level work separately.
"A decreasing geometric series with infinitely many terms sums to infinity, so I can't bound the root case."
Wrong — a geometric series with ratio converges to a finite constant times its first term (, see Geometric Series). That's exactly why the root's cost dominates.
"Binary Search recurrence has levels each doing work, so ."
Wrong — each level does work (there is only one node per level, and ). Summing over levels gives .
"For the ratio is still , so I can read off the case."
Wrong is not a pure power , so no single exists. You must plug it into directly and sum; the clean shortcut only applies to .
"Because isn't a whole number, the recursion tree method is invalid."
Wrong — the tree gives the correct order despite the fractions. Floors/ceilings change sizes by less than , altering the result by only constant factors that ignores; a full proof uses substitution with the ceiling.

Why questions

Why does the tree level method give the same three cases as the Master Theorem?
Because the level sums form a geometric series whose ratio decides everything: (root), (balanced/), (leaves) — that's precisely the Master Theorem's three cases, derived not memorized.
Why do we write only the non-recursive cost in each node?
Because the recursive calls are represented by the node's children, not by its own label. Including them would double-count — the tree already unfolds the recursion structurally.
Why is the number of leaves rather than something involving ?
Leaf count depends only on how the problem splits — branching over depth — giving . The work function affects per-node cost, not how many nodes exist.
Why can an algorithm with more branches () still be slower-growing than one with fewer, if differs?
Growth is a tug-of-war between splitting (, ) and per-call work () via the ratio . Large can be beaten by a large , so branching alone doesn't decide dominance.
Why does the longest branch, not the shortest, determine the height of an unbalanced tree?
The tree isn't done until every branch reaches the base case; the slowest-shrinking branch is the last to finish, so it fixes the maximum depth (and the height bound you use).
Why is it safe to ignore floors and ceilings when reading off a answer?
Rounding a size up or down changes it by less than , so depth and per-level work move by only constant factors — and is defined to ignore constant factors. The clean analysis therefore lands on the correct order.
Why is finding the per-level ratio more reliable than "just counting levels"?
Counting levels only helps in the balanced case where each level costs the same. The ratio tells you whether levels are balanced, growing, or shrinking — without it you can't know if a factor even applies.
Why does not fit the neat three-case table, and what does the tree give instead?
Because isn't a power of , the level sums aren't a clean geometric series. Substituting into and summing (e.g. for ) yields — a result the pure table can't produce.

Edge cases

What happens to the tree when (only one subproblem per call), as in Binary Search?
The tree becomes a single path, not a branching tree: node per level, levels. Total is just the sum of along that path.
What if (constant work per call)?
Then per-level work is , which grows with depth whenever . The leaves dominate and — pure branching cost.
What if is not a power of , e.g. ?
Substitute directly: , which sums over levels to . The tree still works even when the shortcut does not apply.
What if (subproblem size never shrinks)?
The recursion never reaches a base case; the depth is undefined (division by ). The tree has infinite depth — the recurrence doesn't describe a terminating algorithm.
What if is not a power of , so is fractional at some level?
The real tree uses or , so branch sizes differ by at most and the depth by at most one extra level. These are constant-factor effects, so the answer computed from the ideal still holds.
At the base case, why do we say each leaf costs instead of literally?
Because is some fixed constant, and constants are under Big-O Notation. What matters is the count of leaves () times that constant.
What is the effect of an additive constant in the recurrence, e.g. ?
The is dominated by at every node, so and the analysis is unchanged — total stays . Lower-order terms vanish asymptotically.
In the balanced case, does the tree depth being vs change the factor?
No — both are , and changing the log base only multiplies by a constant (). The final is base-independent.

Connections

  • Master Theorem — every trap here maps to one of its three cases.
  • Divide and Conquer — the tree is the natural picture of splitting problems.
  • Substitution Method — the algebraic partner: guess from the tree, prove by substitution (and rigorously handle floors/ceilings).