QamoosTech
Programming FundamentalsIntermediate

Recursion

Pronunciationrih-KUR-zhun

Definition

When a function calls itself to solve a smaller version of the same problem, until it reaches a simple base case.

Where you hear it

Algorithm courses, interviews, and tree or folder traversal.

Examples

  • Walking through folders is a classic use of recursion.
  • The recursion has no base case, so it crashes with a stack overflow.

Common mistake

Forgetting the base case. Without it the function never stops.