Loading…
Play, pause, and step through classic algorithms — with real source code in multiple languages, right in your browser.
A function that calls itself on smaller inputs until a base case. Fibonacci shows the branching call tree grow and unwind — and why naive recursion repeats work.
Splits a problem into halves, solves each recursively, then combines their answers. Here it finds an array's maximum — the same pattern that powers Merge Sort and Quick Sort.
Caches each recursive result the first time it is computed, so repeated subproblems return instantly. The same fib tree collapses from exponential to linear.
Explores the 0/1 knapsack decision tree, but computes an optimistic bound at each node and prunes any branch that cannot beat the best solution found so far.
Makes an amount by repeatedly taking the largest coin that fits. Fast and optimal for canonical coin systems — but the demo also shows a set where greedy fails.