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.
Call stack is empty
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.
Put this into practice
Connect the idea to a worked lesson, a practical task or your interview preparation.
- Concept guideFunctions and Scope →Packaging logic into a reusable, named unit, and the rules for what it can see.
- Practice problemNth Fibonacci Number (Memoized) →Solve this medium problem with samples, hints and checks in your browser.
- LessonPython Functions: Defining, Calling, and Returning →Learn Python functions from scratch - def syntax, parameters versus arguments, return values, keyword and default arguments, *args, **kwargs, and scope.
- Interview prepCoding & DSA interview questions →The concepts behind data-structure and algorithm interview questions — paired with the practice problems that let you actually write the code.
Last updated: