RareProgramming
What is caching a subproblem’s result for later calls called?
Short answer
Memoization
Exercise
- Tabulation
- Memoization
- Greedy search
- Exhaustive search
- Merge sort
Solution
A later call with the same arguments uses the cached result.
Memoization stores a result under a key, for example the index of a Fibonacci number. The first call computes F(3) and stores two. When a different branch requests F(3), it gets the value immediately without expanding its children again.
F(5) → F(4) → F(3) = 2; cache[3] ← 2. F(5) → F(3) → cache[3] = 2.
A state must uniquely specify the remaining subproblem. Different routes through the computation that reach the same state can reuse the same previously computed value.
Platforms
- MAXIMUM
