Definition:
- In a long function, store a few variables to use it later so that it would take less time
Subproblem with Bellman equation:
- Same as Recursive Backtracing with memorization of the value of i that passed through
- Only with work over-lappting function
- Ex: calculating Fib(n) with O(n)
- Tabulation
- Build an array and get solution from bottom up
- backtrack based on the memoization table without explicitly storing values (by checking which case was chosen)
- example: Weighed Interval Scheduling problem:
- Only remember the last i results to find the next one
- ex: Maximum Subarray Problem:
- Opt(i)=
- xi if i=1
- max(xi,xi+Opt(i−1)) if i>1)
- Tkae only element i or take element i together with best subarray endding at index i−1
Some example problems: