Help with Unbounded Knapsack

Let's talk about algorithms!

Moderator: Board moderators

Post Reply
New poster
Posts: 1
Joined: Wed Aug 04, 2010 2:21 am

Help with Unbounded Knapsack

Post by danielperaza »

Hi! I have built an implementation of the unbounded knapsack algorithm by using dynamic programming. It is just a simple function that builds up the table of weights vs. profits like this one:

Code: Select all

[0, 0, 0, 7, 11, 12, 14, 18, 22, 23, 25]
That's fine. The problem is that I'm stuck trying to make the recursion backwards to find which objects were put into the knapsack by the algorithm.

Any ideas? does anyone have a code stub?

New poster
Posts: 11
Joined: Fri Nov 08, 2013 11:04 pm

Re: Help with Unbounded Knapsack

Post by matheusdallrosa »

if you save the best previous item of each item i think that in the and you will have the list, make some tests and reply.

Post Reply

Return to “Algorithms”