Visual walkthrough — Classic recursion — factorial, Fibonacci, binary search
We only need a handful of ideas, and we will earn each one before we use it. Let us begin at absolute zero.
Step 1 — What "call itself on a smaller problem" actually looks like
WHAT. A function is a named machine: you feed it an input, it hands back an output. When we write we mean "run the factorial machine with the number inside it".
WHY a smaller copy. Look at the definition the parent gave us: Term by term: is what we are trying to compute; is the number we currently hold; and is the exact same question asked about a number one smaller. That last piece is the whole trick — the problem contains a shrunken copy of itself.
PICTURE. Below, each machine is a rounded box. A box cannot finish until the smaller box inside it finishes. The boxes nest like Russian dolls, shrinking , until the smallest doll () needs no help.

Step 2 — The stack fills going DOWN
WHAT. When needs , it pauses itself and writes a note: "I still owe a multiplication by once the answer comes back." That note is a stack frame — a little memory box the machine keeps.
WHY it must pause. The multiplication cannot happen yet, because the is not known. So the machine parks the half-done work and dives deeper. Each dive adds one frame.
PICTURE. Read the tower top-to-bottom. Each new call stacks a frame below the last (this is the "piling up" the parent mentioned). Notice the pending work written on the right of every frame — that is what waits.

Each is "I paused and asked a smaller me". The chain stops the instant it hits .
Step 3 — The stack empties going UP (the unwind)
WHAT. The base case returns immediately. Now the parked frames wake up bottom-first, each doing its one waiting multiplication.
WHY bottom-first. The frame added last is the one whose smaller question got answered first, so it resumes first. This is exactly why a stack is used: last in, first out.
PICTURE. Same tower as Step 2, now read bottom-to-top with green return arrows. Watch the number travel upward, getting multiplied at each floor: .

Each labelled brace is the value a floor returns; each arrow is the multiplication that floor was waiting to do. The final is .
Recall Why factorial costs
Its recurrence is : "the work for equals the work for plus one chunk (a single multiply)." The tower has one floor per number from down to : that is floors, each costing . Adding that many times gives , which grows in step with → . See Big-O Notation.
Step 4 — Fibonacci: the box that opens TWO boxes
WHAT. Factorial opened one smaller box. Fibonacci's rule opens two: is the number we want; and are the two smaller questions we must ask. Because the rule reaches back two steps, we need two base cases (, ) — otherwise a branch would fall below and never land.
WHY this makes a tree, not a tower. One box that spawns two boxes, each of which spawns two more, is not a straight line — it branches. That branching is the source of all the trouble.
PICTURE. The call tree for . Follow the split at every node. Circle the two nodes labelled : they are computed in separate branches that never talk to each other.

Step 5 — WHY the naive tree is slow (the derivation)
WHAT. Let be the number of calls the naive makes. Every call to (for ) makes exactly the calls of plus the calls of , plus itself: That is the same shape as the Fibonacci recurrence itself — the count of calls grows like Fibonacci numbers grow.
WHY it grows like , not . If every box opened two full-size boxes, the count would double each level → . But it does not: one branch is size and the other is only — the second branch is shorter, so the tree is lopsided, not a full doubling. The true growth rate is the number that satisfies the sequence's own multiply-rule: Term by term: is "two steps of growth", and it equals " (one step) plus " — the exact reach-back-one-and-two pattern. So each increase of by one multiplies the work by about (not ), giving . Slower than doubling, but still explosive.
PICTURE. The same tree, now with repeated subtrees painted the same colour. Every extra copy of a colour is pure wasted recomputation — and the two branches below any node are visibly unequal in height, which is why the base is and not .

Step 6 — Memoization: cross out the duplicates
WHAT. Keep a notebook (memo) mapping "" → "". Before computing , peek in the notebook. If it's there, hand it back instantly; if not, compute once and write it down.
WHY it collapses the tree. After the first time we solve , every other node becomes a single instant lookup — its whole subtree is deleted. The branching tree flattens into a slim path.
PICTURE. The tree with duplicate subtrees crossed out and replaced by a "cache hit" tag. What's left is a thin chain — only genuine computations.

The arrow reads "adding the notebook turns exponential into linear."
Step 7 — Binary search: throwing away half a picture at a time
WHAT. Given a sorted list, we compare the target to the middle element and discard the half it cannot be in. lo and hi are the left and right edges of the region still in play; mid is the middle index .
WHY the middle, and why sorted. In a sorted list, everything left of mid is smaller and everything right is bigger. So one comparison at the middle safely rules out a whole half — but only because the order guarantees it. On unsorted data the "throw away a half" logic is a lie.
PICTURE. Searching in the list . Three shrinking bars: the greyed-out region is the half thrown away; the highlighted region is what survives; the arrow marks mid each round. Round 1 checks the middle value ; since we keep the right half. Round 2 checks ; since we keep the left half. Round 3 lands exactly on and returns its index . Read the picture left-to-right, top-to-bottom — every number and decision is drawn on it.

WHY . Its recurrence is : "the work for items equals the work for half of them, plus one chunk (the single middle comparison)." Starting from and halving repeatedly — — takes about halvings, each costing . So the total is about → .
Step 8 — The edge cases you must never trip over
WHAT & WHY. Every recursion has quiet corners. Draw them so no reader is ever surprised:
factorial(0)— base case fires immediately, returns . No dive. (Smallest problem answered directly.)fib(0)andfib(1)— both base cases; either would recurse below if missing.- Binary search, target absent (e.g. ): the region keeps halving until
lo > hi— an empty range. That is the "not found" base case; it returns . - Binary search on an empty list:
hi = len(arr)-1 = -1, solo(0) > hi(-1)is true on the very first call → returns with zero comparisons.
PICTURE. The "target absent" path: lo and hi cross over, leaving no bars highlighted — the moment recursion stops with "not found".

The one-picture summary
All three recursions on one canvas: factorial's straight tower (each step , cost ), Fibonacci's branching tree collapsed by a notebook, and binary search's halving bars (cost ). The three silhouettes — a straight column, a lopsided tree, and shrinking bars — are the whole page in one glance.

Recall Feynman: the whole walkthrough in plain words
Recursion is a stack of paused workers. Factorial: worker can't finish until worker finishes, who waits on worker , who waits on worker — the only one who knows the answer straight away. Worker says "", and the answer climbs back up, getting multiplied on every floor: . Fibonacci does the same but each worker calls two helpers, so if nobody writes anything down the same little questions get re-asked a mountain of times — write them in a notebook and the mountain flattens. Binary search is a worker looking in a sorted phone book: open the middle, throw away the half your name isn't in, repeat. Each glance deletes half the book, so you're done in about glances. When the book has nothing left to throw away, the name wasn't there.
Connections
- Recursion vs Iteration — the tower and halving pictures become loops
- Big-O Notation — where , , come from
- Memoization and Dynamic Programming — the notebook in Step 6
- Divide and Conquer — binary search is the halving picture
- The Call Stack and Stack Frames — the towers in Steps 2–3
- Sorting Algorithms — binary search's precondition