recursion_tree.svg
Current level
Already expanded
Not yet opened
What is the Recursion Tree Method
A recursion tree unrolls T(n) = a T(n/b) + f(n) into levels. The root does f(n) work, each child does f(n/b), and so on until size 1. Add the work level by level. A geometric series on those level-costs is the closed form.
Interactive recursion tree
Pseudocode & Complexity
| Operation | Time |
|---|---|
| Merge sort 2T(n/2)+n | O(n log n) |
| Binary search T(n/2)+1 | O(log n) |
| Tree walk 2T(n/2)+1 | O(n) |
| 3T(n/2)+n | O(n^{log₂ 3}) |
| Space | — |