Dynamic Programming
Sometimes when trying divide and conquer approach, we are only able to divide in a way which makes us perform “exhaustive search”
- Bad divide and conquer
However, in several situations, it turns out that a small set of particular subproblems appear several times in our recurrence
Instead of recomputing the subproblems, we can:
- Solve them once
- Save them to memory
- If we need them again, we already precomputed them
DP template
- Identify small set of subproblems
- Devise proper recursion
- Show bottom-up approach correctly compute the subproblems