🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Programming Concepts Intermediate

What is Memoization?

An optimization technique that caches function results for given inputs, avoiding redundant computations for repeated calls.

Memoization stores the results of expensive function calls and returns the cached result when the same inputs occur again. In Python: @functools.lru_cache decorates a function to automatically memoize results.

Memoization is key to dynamic programming, where overlapping subproblems would otherwise cause exponential time complexity. Classic examples include Fibonacci numbers (O(2^n) → O(n)), pathfinding, and string matching. It trades memory for speed.

Related Terms

Race Condition
A bug that occurs when the behavior of software depends on the timing or order of uncontrolled events like thread scheduling.
Composition over Inheritance
A design principle favoring object composition (has-a relationships) over class inheritance (is-a relationships) for code reuse.
DRY (Don't Repeat Yourself)
A software development principle that aims to reduce code duplication by abstracting common patterns into reusable components.
Design Pattern
A reusable solution template for commonly occurring problems in software design.
Recursion
A programming technique where a function calls itself to solve a problem by breaking it into smaller subproblems.
Concurrency
The ability of a program to manage multiple tasks that can make progress during overlapping time periods.
View All Programming Concepts Terms →