Recursion Visualizer: Call Stack and Recursion Tree
Recursion is hard to picture on paper. Paste a recursive function and press ▶ Explain: the call stack beside the variables shows every call in progress, and the recursion tree grows call by call, turning each box green with its return value when it finishes.
- Live call stack: fact(4) on top of fact(5) on top of main()
- Recursion tree: every call as a box, with the value it returns
- The running call is highlighted; click any box to jump to that call
- The line of code and the flowchart box light up at each step
- Works for C, C++, Java, Python and JavaScript
- Viva questions on base cases, stack depth and complexity
How it works
- Paste your recursive program and a small input
- Press ✦ Make flowchart
- Press ▶ Explain
- Watch the call stack and the 🌳 Recursion tree tab
Try it with
- #include <stdio.h> int fact(int n) { if (n <= 1) return 1; return n * fact(n - 1); } int main() { printf("%d", fact(4)); return 0; }
- def fib(n): if n < 2: return n return fib(n - 1) + fib(n - 2) print(fib(4))
- static int sumDigits(int n) { if (n == 0) return 0; return n % 10 + sumDigits(n / 10); } public static void main(String[] args) { System.out.println(sumDigits(472)); }
Frequently asked questions
What is a recursion tree?
A diagram of every call a recursive function makes: each call is a box, its children are the calls it makes, and the value under each box is what it returns. For fib(4) it shows why the same values are computed more than once.
What does the call stack show?
The calls that are still running at that moment, newest on top, with their argument values. It grows as the function calls itself and shrinks as each call returns.
Is it free?
Yes. A dry run uses one free AI credit, and the three examples above open without signing up.
Can I export it?
Yes — PNG, SVG, PDF, PowerPoint with an editable slide, Mermaid code and draw.io. You can also share a live link or present it full screen.
Classic programs with flowchart, algorithm and code
- Prime Number Check: flowchart, algorithm and program
- Factorial of a Number: flowchart, algorithm and program
- Fibonacci Series: flowchart, algorithm and program
- Palindrome Number: flowchart, algorithm and program
- Armstrong Number: flowchart, algorithm and program
- Reverse a Number: flowchart, algorithm and program
- Sum of Digits: flowchart, algorithm and program
- Leap Year: flowchart, algorithm and program
- Largest of Three Numbers: flowchart, algorithm and program
- Bubble Sort: flowchart, algorithm and program
- Binary Search: flowchart, algorithm and program
- Factorial Using Recursion: flowchart, algorithm and program
- All 88 programs →