Skip to content
BytePatterns

Recursion

Watch the call stack grow, shrink, and finally make sense.

Recursion progress0 / 8
  1. Recursion BasicsA function that solves a smaller copy of itself.5m
  2. The Call StackEvery pending call waits its turn on a stack of frames.5m
  3. Factorial and FibonacciOne call per step, or two calls that redo everything.6m
  4. MemoizationWrite each answer down once, never solve it twice.5m
  5. BacktrackingChoose, explore, then undo the choice and try the next.6m
  6. Return Up or Pass DownEvery recursion moves information one of two ways. Pick one.6m
  7. Tail Calls and LoopsWhen nothing happens after the call, the frame is dead weight.6m
  8. Your Own Call StackNot a tail call? Then carry the stack yourself.6m

Quiz yourself: 3 questions from this module

1 / 3

What keeps a recursive function from running forever?