AI engineering glossary · Data structures algorithms

What is recursion?

Recursion: A technique in which a function solves a problem by calling itself on a smaller version of the same problem until it reaches a case simple enough to answer directly. It suits trees, nested data and divide and conquer.

Level: beginnerTopic: Data structures algorithms

Recursion: an example

factorial(4) = 4 * factorial(3), which continues down to factorial(1) = 1, then multiplies back up to give 24.

Related terms

More Data structures algorithms terms

Where you learn it

Recursion is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.