Time Complexity via Divide-and-Conquer Recurrences (Two Worked Examples)
This section teaches how to compute asymptotic running time for two recurrences—one “variable-size divide-and-conquer” and one “incremental” recurrence.
We will solve:
We’ll use a standard “recurrence tree / unfolding” strategy for (i) and summation (telescoping / series) for (ii).
type="tip" title="Pro Tip" content="When the subproblem size changes nonlinearly (like ), switch from Master Theorem to recurrence-tree/unrolling and track how many levels occur and what each level costs."
Key keywords you’ll use
- Recurrence
- Recurrence tree
- Unrolling
- Base case
(Next, we do the full derivations.)
Solve (i) T(n)=√n·T(√n)+n via recurrence-tree unrolling
- 1Step 1
Let and define , so .
- 2Step 2
At level , the recurrence contributes a factor of in front of the next . Since , we get .
- 3Step 3
At each level, the additive term contributes (because the '+n' in becomes '+(current subproblem size)' when unfolded).
- 4Step 4
Stop when (or any constant). Solve → → , hence .
- 5Step 5
Total cost is approximately Using Thus the level- term becomes .
- 6Step 6
Each level contributes , and there are levels, so
Result for (i)
Why this happens (intuition):
Unrolling produces about levels because each step takes a square root, so the exponent shrinks geometrically. Meanwhile, although the subproblem sizes shrink, the multiplicative factor from expands in exactly the right way so that the effective cost per level stays on the order of .
type="warning" title="Common Pitfall" content="Do NOT apply the standard Master Theorem directly here: the subproblem size is but the number of subproblems is effectively variable (the multiplier is , not a constant ). That’s why recurrence-tree accounting/unrolling is safer."
Solve (ii) T(n)=T(n-1)+1/n using telescoping unrolling
- 1Step 1
"For iterate:
- 2Step 2
"Let . Then
- 3Step 3
A standard fact is , so
Result for (ii)
Intuition:
You add each step. Summing from to yields the harmonic series, which grows logarithmically.
Asymptotic running time comparison
Two different recurrence styles yield distinct growth rates.
Learning roadmap for these recurrence types
Identify recurrence structure
Step ACheck whether coefficients/subproblem sizes are constant or variable (e.g., multiplier)."
Choose the right method
Step BUse unrolling/recurrence tree for variable divide-and-conquer; use telescoping/sums for linear recurrences."
Count levels and sum per level
Step CFor -style recurrences, levels are about ."
Convert sums to known series
Step DFor , use harmonic growth ."
FAQs and edge cases
Knowledge Check
For , the number of recurrence-tree levels is approximately: