Data Structures

Recursion

Definition

A technique where a function calls itself to solve smaller instances of the same problem. Every recursive function needs a base case (stopping condition) and a recursive case. Common in tree traversals, divide-and-conquer algorithms, and mathematical computations.

Code Example

Javascript
Tip: Modify the code above and click “Run” to see the results

Learn More

Related Terms