Your concept feed

12 ideas

A few small steps. No rush.

Follow the connections in this topic

Let’s picture it

Open a box.

Big box
Small box
Empty

There’s a smaller box inside. We already know how to open a box.

Swipe when you’re ready
One little change

Do the same small job again.

Big box
Small box
Empty

Open the smaller box. Keep going until there isn’t another box inside.

Same idea. One more small step.
Now it has a name

That’s the idea of recursion.

smaller
smaller
stop

A function asks itself to handle a smaller case. The empty box is our stopping point: the base case.

Want to try a tiny question?
No pressure. Just try it.

What if every box contains another box forever?

You can also keep scrolling
1 / 4
Recursion

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Same door. One small difference.

You + key
Locked door

You have a key. Your friend doesn’t. The door is the same, but your next move isn’t.

1 / 3
Let’s picture it

A question can make two more.

ways(4)
ways(3)
ways(2)

Climb one or two stairs at a time. Four stairs can lead to a smaller question with three or two left.

Swipe when you’re ready
One little change

Look, the same question returns.

ways(3)
ways(2) again

ways(3) also asks for ways(2). We’ve reached that smaller question twice.

Same idea. One more small step.
Now it has a name

Notice the repeated work.

ways(2)
save answer
reuse

Draw the calls to spot repeated questions. Later, we’ll save their answers instead of solving them again.

Want to try a tiny question?
No pressure. Just try it.

Do two calls with the same input always need separate work here?

You can also keep scrolling
1 / 4
Recursion

One small step at a time.

This idea builds on these smaller ones. Pick any to revisit it here.

Open a box.

Big box
Small box
Empty

There’s a smaller box inside. We already know how to open a box.

1 / 3
You've reached the end of these ideas.Try them without the labels