AI engineering glossary · Data structures algorithms

What is memoization?

Memoization (also called top-down dynamic programming): A top-down optimisation that saves the result of each function call for given arguments and returns the saved value if the same call happens again. It turns exponential recursion into polynomial work when subproblems repeat.

Level: intermediateTopic: Data structures algorithms

Memoization: an example

Wrapping a recursive Fibonacci function with functools.lru_cache makes fib(50) return immediately instead of repeating billions of calls.

Related terms

More Data structures algorithms terms

Where you learn it

Memoization 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.