← Back to All Engineering Simulators
📖 View Subject LaTeX Notes →CS101Python Programming & Algorithmic Thinking • Intermediate
Function Call Stack & Recursion Visualizer
Step 1 of 6● Stack Depth: 1
Initial Invocation: fact(3)
A new activation frame for fact(3) is pushed onto the stack. It cannot complete until fact(2) returns.
Input (n):
Active Memory Region
1 Active FrameCall Stack (LIFO Tower)
ACTIVE TOP FRAMEfact(n=3)
Return: waiting...Evaluates n <= 1 (False). Calls fact(2)...
Active Python Sourcerecursion.py
1def fact(n):◀ EXECUTING
2 if n <= 1: return 1 # Base Case
3 return n * fact(n - 1) # Recursive Step
Interactive Terminal OutputSTDOUT
>>> fact(3) pushed to Call Stack [Line 1] Calling fact(n=3)
Mathematical Model
Theory & Governing Equations
Analytical principles modeled in this interactive visualizer:
Base Case: T(0)=c, Recursive Step: T(n) = T(n-1) + O(1)
Key Exam Concepts:
- Each function call creates a new stack frame storing local variables, formal parameters, and return address.
- When the base case is reached, stack frames pop in Last-In-First-Out (LIFO) order.
⚡ Browser-Native Runtime
This simulator executes at 60 FPS directly in your browser using client SVG, HTML5 Canvas, and React state.