Recursion: Fibonacci
easy 16 minFibonacci is the classic example of tree recursion: fib(n) = fib(n - 1) + fib(n - 2) with base cases fib(0) = 0 and fib(1) = 1.
Where it shows up
The same pattern appears across everyday software.
Spirals in plants
Sunflower heads, pinecones and pineapples arrange their seeds and scales in two sets of spirals, and the two counts are very often neighbouring Fibonacci numbers such as 34 and 55. Each new seed grows at a turn of about 137.5 degrees, the golden angle, which packs seeds evenly.
Fibonacci heaps and Fibonacci search
The Fibonacci heap, a priority queue used in theory-optimal versions of Dijkstra's and Prim's algorithms, gets its name because a node's subtree size is bounded below by a Fibonacci number. Fibonacci search narrows a sorted range by Fibonacci-sized steps instead of halves.
Agile estimation
Many teams estimate work in story points on a modified Fibonacci scale (1, 2, 3, 5, 8, 13, 20...). The growing gaps reflect that bigger tasks are harder to estimate precisely.
Art, design and the golden ratio
Ratios of neighbouring Fibonacci numbers approach φ ≈ 1.618. Designers use golden-ratio grids, spirals and type scales built from these numbers for proportions that feel balanced.
Trading charts
Technical analysts draw Fibonacci retracement levels at 23.6%, 38.2% and 61.8% of a price move, ratios that come from dividing Fibonacci numbers. It is a charting convention, not a law of markets.
The textbook dynamic programming example
Courses and interviews use Fibonacci to introduce memoisation and tabulation because the repeated subproblems are easy to see. The same refactor speeds up real recursive code such as parsers, pricing models and path counting.