Recursion Tree Visualizer

Build a recursion tree, step through calls and returns, and watch the active call stack change as each recursive branch completes.

Calls
15
Depth
4
Result
5
Step
1

Example input

Step controls

Call fib(5).

Active call stack

fib(5)

Fibonacci recursion

Step 1 of 30: Call fib(5).

Stack path Call Return
Recursion treeRecursion tree with 15 calls and max depth 4.fib(5)= 5fib(4)= 3fib(3)= 2fib(2)= 1fib(1)= 1fib(0)= 0fib(1)= 1fib(2)= 1fib(1)= 1fib(0)= 0fib(3)= 2fib(2)= 1fib(1)= 1fib(0)= 0fib(1)= 1

Call and return log

1. Call fib(5).

What this shows

Every box is one function call. Child boxes are calls made before the parent can return.

The highlighted path is the call stack: the active chain that must unwind before control returns to the caller.

Fibonacci and binary branching show why repeated recursion can grow much faster than a single-chain factorial call.

What is a Recursion Tree Visualizer?

A recursion tree visualizer draws each recursive call as a node, then shows how calls expand and return. It is useful for understanding recursion depth, branching, base cases, repeated work, and call stack behavior.

This page includes factorial, Fibonacci, and binary recursion examples so you can compare linear recursion with branching recursion.

For the full cluster of related tools, browse the Data Structure Visualizers hub.

How to use this recursion visualizer

  • Choose a recursion example.
  • Pick an input size.
  • Build the call tree.
  • Step through calls and returns.
  • Inspect the active call stack and final return value.

The call tree shows the shape of recursion. The call stack shows what is currently active at a specific step.

Recursion tree vs call stack

A recursion tree shows all calls that happen across the whole execution. A call stack shows the current chain of active calls at one moment.

If you are comparing recursion with stack-style iteration, use the Stack and Queue Visualizer. For recursive choice trees and undo steps, try the Backtracking Visualizer. For branching recursion that becomes dynamic programming, try the Knapsack DP Visualizer.

Frequently Asked Questions

What does a recursion tree show?
It shows each recursive call and the child calls created by that call.
What does the call stack show?
The call stack shows the active calls waiting to return at the selected step.
Why does Fibonacci create a large tree?
Naive Fibonacci recursion branches into two calls for most inputs, so repeated subproblems grow quickly.
Can I change the recursion input?
Yes. Choose the example and set n to build a smaller or larger recursion tree.

Related tools