Recursion occurs when a function calls itself to break down a problem into smaller base cases. The Fibonacci sequence demonstrates call stack frames and exponential branching.
Opening a doll reveals a smaller doll inside. You keep opening smaller dolls until you reach the solid center doll (Base Case).
500 steps (Linear)
O(N × W) Memoized Time
O(N × W) Cache Matrix
Memory growth rate as N expands.
Relative efficiency rating for large N.
| Operation | Time Complexity | Space Complexity |
|---|---|---|
| Naive Recursion | O(2ⁿ) | O(N) |
| Memoized DP Recursion | O(N) | O(N) |
function fib(n) {
if (n <= 1) return n;
return fib(n - 1) + fib(n - 2);
}Recurses left and right child nodes naturally.
Powers Quick Sort and Merge Sort functions.
Validate your conceptual understanding, operation mechanics, and core concepts of Recursion Fibonacci.
Always define your base case FIRST in recursive functions to avoid stack overflow crashes!
Recursion stack visualizer. Enter target n (0 to 5) and click Run Recursion.