Recursion Visualizer — Call Stack, Fibonacci & Towers of Hanoi | Interview Prep Buddy
Back to Visualizers Hub
🔄

Recursion

Recursion is a programming technique where a function calls itself to solve smaller subproblems.

ALGORITHM PATTERN

Recursion & Call Stack1. Factorial n! (Linear Stack Winding)

🎯 Expected:4! = 4 × 3 × 2 × 1 = 24
Milestones:
step 1 / 7
Call Stack Frame Inspector Canvas
Call Stack Memory (LIFO)
Frame #1fact(4)◀ TOP
Call Stack Depth: 1 FramesExecution Phase: Winding Down ⬇️
Concept Code
1if n <= 1: return 1 // Base Case
2return n * factorial(n - 1) // Recursive Step
State Variables
n4
n <= 1FALSE ❌
phaseWinding Down ⬇️
✏️
line 1Line 1: Call fact(4). Check base case (4 <= 1): FALSE.