Home▸Algorithms & AI▸Algorithms Simulation

Recursion & the Call Stack: Fibonacci vs Factorial

Interactive recursion-tree and call-stack simulator: watch naive vs. memoized recursive Fibonacci (and factorial) unfold call by call in 3D, with live call counts, stack depth and cache-hit stats.

Algorithms & AI2DModerate60 FPS📱 Mobile-adapted
computer-science-algorithms-simulation ↗ Open standalone

This simulation explores the fundamental concepts of algorithms by making one of the trickiest to build intuition for — recursion — visible call by call. A real recursive JavaScript function computes Fibonacci numbers (or factorials) while every call and return it makes is logged in order, then replayed as two linked 3D views: a growing recursion tree where each node is one function call, and a call stack column that pushes a frame on every call and pops one on every return, exactly as it happens inside a real interpreter. A memoization toggle demonstrates, with live call-count and cache-hit readouts, how caching repeated sub-problems collapses an exponential-time recursion into a linear one — one concrete algorithmic approach among the many this simulator's broader catalogue tackles.

⚙ Under the hood

This simulation explores the fundamental concepts of algorithms – step-by-step procedures for solving problems. It demonstrates how different algorithmic approaches can be used to tackle various computational challenges.

Algorithms SimulationSorting Algorithms

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)