The name "Dynamic Programming" is a misnomer.
Motto of Dynamic Programming
Dynamic Programming (DP) is a algorithm design paradigm that includes the following features:
- Algorithms are recursive
- There are overlapping recursive subproblems
- Memoization can be used to reduce re-solving overlapping subproblems
- You can also write an iterative solution which can be easier to analyze
Think of DP as a "filling in a table" problem
To devise a DP solution to a problem, you must
- Understand which subproblems overlap
- Recursion trees help in identifying overlap
- Understand the subproblem dependencies (which subproblems to solve first)
- How to break ties (e.g. minimum or maximum of two dependencies)
- Choose which order to iterate
- Iterate from
- Iterate for increasing from
- Iterate on all notes of a Tree, where the data is stored in the tree node itself.