How Does Recursion in 100 Seconds Work?

Recursion is when a problem solves itself by breaking into smaller copies of itself, like stacking blocks one on top of another until you reach the bottom.

Imagine you're trying to climb up a never-ending staircase. Each time you take one step, it's like asking, "Can I do this again?" If the answer is yes, you keep going, and that’s recursion in action!

Like a Russian Doll

Think of Russian dolls, each one opens up to reveal another smaller doll inside. You keep opening them until you get to the tiniest one. That's like how recursion works: it keeps solving little parts of the problem until it gets to something simple enough to know the answer.

Counting Blocks

Say you have a tower of 10 blocks, and you want to count them all. You take the top block, count it as 1, and then ask, "How many blocks are left?" Now you're counting a tower with 9 blocks, that’s recursion!

It's like having a friend who helps you count by doing the same thing again and again until there are no more blocks to count. Then, you add up all the little counts to get the big total.

Take the quiz →

Examples

  1. A child counts down from 10 to 0, and each number triggers the next.
  2. A tree grows by adding one branch at a time until it reaches its full height.
  3. A person tells a joke, then repeats the same joke with a new twist.

Ask a question

See also

Discussion

Recent activity