0/1 Knapsack Dynamic Programming Optimazion, from 2D matrix to 1D matrix
I need some clarification from wikipedia: Knapsack , on the part This solution will therefore run in O(nW) time and O(nW) space. Additionally, if we use only a 1-dimensional array m[W] to store the current optimal values and pass over this array i+1 times, rewriting from m[W] to m[1] every time, we get the same result for only O(W) space. I am having trouble understanding how to turn a 2D matrix into a 1D matrix to save space. In addition, to what does rewriting from m[W] to m[1] every time mean (or how does it work). Please provide some example. Say if I have the set {V,W} --> {(5,4),(6,5),(3