As for 0~1 knapsack problem,
f[i][v]=max{f[i-1][v],f[i-1][v-c[i]]+w[i]}
c[i] means the cost of ith goods,
w[i] means the value of ith goods.
And I read one doc,which said the time complexity can be optimization,especially when V is larger.as below
i=1...N
v=V...0
can be changed to
i=1...n
bound=max{V-sum{w[i..n]},c[i]}
v=V...bound
what does it mean?How can V(the maximum of bag) minus sum of w[i](the value of goods)?
Really confuse,or something wrong on this doc?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…