๐ŸŽ 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

Clean Code
Code that is easy to read, understand, and maintain - following consistent conventions, meaningful naming, and single-responsibility functions.
Factory Pattern
A creational design pattern that provides an interface for creating objects without specifying their exact classes.
SOLID Principles
Five design principles for writing maintainable, flexible object-oriented code: Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.
Twelve-Factor App
A methodology of twelve best practices for building modern, scalable, maintainable software-as-a-service applications.
Refactoring
Restructuring existing code without changing its external behavior to improve readability, maintainability, and performance.
Stack vs Heap
Two memory regions: the stack stores function call data with automatic cleanup, while the heap stores dynamically allocated objects.
View All Programming Concepts Terms โ†’