Why does naive recursive Fibonacci recompute the same values, and how does a dictionary memo make fib(120) instant?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Every call fib(n) counts as one call, plus all the calls its two recursive children make; fib(0) and fib(1) make no further calls. Define a recursive function numCalls(n) that returns the total number of calls the naive fib makes when you call fib(n).