I've been studying dynamic programming as part of a course and have struggle for a few days with the DP solution for the knapsack 0-1 problem. My understanding of the problem and solution is this:
we have items (A, B, C, D), a knapsack that holds weight W = 10 maximum, and the weights/values of each item is A = 2w/1v, 2w/3v, 5w/8v, 6w,5v.
The solution requires that we look at subproblems where we restrict the knapsack weight from 0 -> W and the items from A -> D.
What I don't understand is
- How does one arrive at this solution intuitively?
- Why does the solution work even if the items are ordered differently since we need to iterate through each of the items?
- How does the DP subproblem solution account for all possible combinations of knapsack solutions if one did this without DP and use a brute-force try all combinations approach?