Home > Back-end > How to understand the state transition equation of 01 knapsack?
How to understand the state transition equation of 01 knapsack?
Time:09-20
Feeling of this code is not very understanding
F [I] [v]=Max {f [v], [I - 1] f] [I - 1 - c [I] [v] [I] + w}
"[I - 1 f] [v] represent just don't put this item in a backpack, and f [I - 1] - [v [I]] c + w [I] is a representative to the case of a value that is put in the bag after I compare the two value, it is concluded that the biggest value into now backpack," An object into a backpack than not, however, in the value of the big ah, this is necessary?
CodePudding user response:
You didn't write a judgment conditions, this is the capacity as a subscript, you have to consider whether the backpack is full
CodePudding user response:
Look at this is not necessary to certain
CodePudding user response:
[v] [I f - 1 - c [I]] + w. [I] To remove a change into another