Skip to content
Hi, Bot

Hi, Bot · First Principles · Phase 3: Calculus and complexity

Lesson 25 of 48

Recursion

A procedure that calls itself and terminates anyway.

Recursion is induction executable: a base case and a step that moves toward it. Once it clicks, trees, parsers and divide-and-conquer stop being separate topics.

Do this

Solve one problem both recursively and iteratively and show the two agree on many inputs. Name your base case and argue the recursive case always moves toward it.

The question that unlocks the next lesson

A recursive function with a correct base case still overflows the stack. Most likely cause?

  • AThe base case is unreachable — the recursive step never moves toward it
  • BRecursion is always slower than iteration
  • CThe function returns the wrong type
  • DThe base case must come last in the function body

Start at lesson 1 and work up to this one

48 lessons, one a day. Answer each lesson's question correctly and the next one opens immediately — nothing here is unlocked by waiting.

By submitting, you agree to our Terms and Privacy Policy.