Multiple recursion occurs when one invocation makes more than one recursive call. The Fibonacci implementation below branches into two calls for every n greater than two, creating a recursive call tree with repeated subproblems. section 7.3
Naive recursive Fibonacci
size_t fib(size_t n) { if (n < 3) return 1; return fib(n-1) + fib(n-2); } The repeated calls make execution time exponential in n. For example, computing fib(4) recomputes fib(2). section 7.3
Use these rules when evaluating multiple recursion:
- Expect exponential computation times when recursive branches repeatedly solve the same subproblems. section 7.3
- Trade storage for computation time with a cache; cached Fibonacci recursion reduces execution time to linear in n. section 7.3
Figure 7.2 Recursive call fib(4)
Trace the recursive call tree for fib(4) and locate repeated subcalls. section 7.3

