🎁 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

Dependency Injection
A design pattern where objects receive their dependencies from external sources rather than creating them internally.
Code Smell
A surface indication in code that usually corresponds to a deeper problem in the system, suggesting the need for refactoring.
Algorithm
A step-by-step procedure for solving a problem or performing a computation, defined as a finite sequence of instructions.
Twelve-Factor App
A methodology of twelve best practices for building modern, scalable, maintainable software-as-a-service applications.
Concurrency
The ability of a program to manage multiple tasks that can make progress during overlapping time periods.
DRY (Don't Repeat Yourself)
A software development principle that aims to reduce code duplication by abstracting common patterns into reusable components.
View All Programming Concepts Terms →