Knapsack Problems: Decision Making DP Problems
Get startedজয় শ্রী রাম
🕉In many Dynamic Programming problems (i.e, problems which show (1) overlapping subproblems, and (2) optimal substructures properties) you would see that for a given situation you would have multiple options for actions you can take. Often times this would involve taking decision whether to use (INCLUDE) or not to use (EXCLUDE) the current state. So, the problem would require you to make a decision at a current state, so that you can get optimal solution for the current state.
More generally, this approach can be summarized as
- If you decide to choose the current value, use the from the already computed results (Optimal Substructure) where the value was ignored.
- If you decide to ignore the current value, use from already computed results (Optimal Substructure) where the value was used.
The chapter House Robber beautifully demonstrates this approach.