Talk:Knapsack problem/Unbounded

From Rosetta Code

Dynamic Python solution

Is the underlying algorithm so different from what I called an exhaustive search solution? I don't think so. P.S: should the line w = sack.volume; v = sack.volume have the first volume replaced by weight?

It's great that you thought the problem worthy of your time though. I spent ages trying to find something beginning with K and then on formulating the problem :-)

--Paddy3118 05:40, 3 December 2008 (UTC)

Yes, in theory. Dynamic programming runs in time polynomial in the size of the sack weight, sack volume, and number of types of items; whereas the exhaustive search runs in time exponential in the number of types of items. But since the number of types of items here is so small (3), you won't see much of a difference. --Spoon! 07:04, 3 December 2008 (UTC)
I'm new to this big-O notation stuff, but I think my algorithm would run in time proportional to:
the product of ( the minimum of ( max_restriction(r)/restriction(r of i) for all restrictions r ) ) for each item i 
I can't see the exponential? --Paddy3118 07:44, 3 December 2008 (UTC)