Recursion and the call stack
easyEvery call gets a stack frame holding its own state. See the frames pile up and unwind, count how many times fib(2) is recomputed, then switch the cache on and watch the tree collapse into a line.
Best
O(n) memoisedWorst O(2ⁿ) naiveSpace O(n) stack depthLoading the recursion and the call stack engine…