๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout 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

Design Pattern
A reusable solution template for commonly occurring problems in software design.
Object-Oriented Programming (OOP)
A programming paradigm that organizes software design around objects containing data and behavior.
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.
Recursion
A programming technique where a function calls itself to solve a problem by breaking it into smaller subproblems.
Refactoring
Restructuring existing code without changing its external behavior to improve readability, maintainability, and performance.
View All Programming Concepts Terms โ†’