Skip to content

DSA Visualizer

Recursion, step by step

Every recursive call adds a frame to the call stack and waits. Watching the stack grow and then unwind is the clearest way to see why a missing base case means it never stops — and why deep recursion has a real memory cost.

(kept small so the stack fits on screen — the idea is the same at any depth)

Watch the call stack grow as each call waits on a smaller call, then unwind as each waiting call finally gets its answer and computes its own result.

Step 1 of 21

Compute factorial(5). Recursion works by breaking a problem into a smaller version of itself, calling itself on that smaller version, and combining the results on the way back.