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.
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
- Merge sort
- Minimum spanning tree
- Monotonic stack
- NP-complete
- Open addressing
- Optimal substructure
- Overlapping subproblems
- P versus NP
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.