Math Fundamentals18 sections · 814 units
Open in Course

Exponential Example

(Naive Fibonacci)

The recursive formula fib(n) = fib(n-1) + fib(n-2) spawns two recursive calls per level. This creates a binary tree of calls with roughly 2n2^n nodes.

fib(3030) makes over 11 million calls. fib(4040) makes over 300300 million. The tree grows exponentially.

Memoization reduces this to O(n)O(n) time and O(n)O(n) space by caching results. Without it, exponential blowup kills performance.