[英]Knapsack formula using only weights as the recursion variable
I have developed a recursive formula for knapsack problem on my own without any knowledge of present solutions. 我自己开发了一个背包问题的递归公式,而对当前的解决方案一无所知。 Please tell me whether it is right or wrong and correct it.Thanks in advance.
请告诉我是对是错,并进行更正。谢谢。
B(S) = max (B (s-w(i)) + b(w(i)) )
for all i
belonging to n
; 因为
i
属于n
; notations are as usual . 记法照常。
S
is capacity, B
is the answer to knapsack. S
是容量, B
是背包的答案。
I do not want to give you straight answer, but to direct you on the flaws of your formula, and let you figure out how to solve them. 我不想给您直接的答案,而是要引导您了解公式的缺陷,并让您找出解决方法。
B(sw(i))
) what happens to the current value? B(sw(i))
),那么当前值会怎样? i
? i
? How do you change i
over time? i
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.