Skip to content

Recursion Tree Visualizer

Visualize recursive call trees step by step

Updated

What is the Recursion Tree Visualizer?

How it works

Examples

Visualize Fibonacci recursion tree

function fib(n) { if (n <= 1) return n; return fib(n - 1) + fib(n - 2); }  args: 7
Tree with 41 nodes, max depth 7, final result 13, animated call-by-call playback with depth coloring

Trace the Euclidean GCD algorithm

function gcd(a, b) { if (b === 0) return a; return gcd(b, a % b); }  args: 48, 18
Linear chain of 4 nodes, max depth 3, final result 6, each step shows argument pair shrinking

Explore Pascal's Triangle binomial coefficient

function pascal(n, k) { if (k === 0 || k === n) return 1; return pascal(n - 1, k - 1) + pascal(n - 1, k); }  args: 5, 3
Branching tree with 13 nodes, max depth 5, final result 10, overlapping subproblems visible

Frequently asked questions