Recursion.
Nesting dolls: solve a problem by doing the same smaller version of it, until one is tiny enough to answer outright.
- Open this.1
A big problem. The trick: it contains a smaller version of the very same problem.
- 2
So do the same job — on the smaller piece.
- 3
Each step stacks up, waiting, as the problem gets smaller and smaller.
- This one I just know.4
Until the smallest case, simple enough to answer outright — the base case.
- 5
Now the answers travel back up, each step finishing once the piece below it is solved.
- Uh oh — no bottom.6
Forget the base case and it never stops — it just shrinks forever (stack overflow).
Semicolony semicolony.dev/eli5/recursion/comic