Skip to content

Recursion

When a function calls itself to derive a solution to a problem

Solving a Recursive Problem

  • Find your base cases
    • Think about the simplest and smallest possible inputs to your function, such that you know the answer immediately
  • Take the recursive leap of faith
    • Identify the behavior of a recursive problem, and implement a solution
    • Typically involves calling your function on a smaller input
    • Trust that your implementation is correct
  • Recombination: Build up the answer to the original problem using the previous result