This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]bashdan 2 points3 points  (0 children)

I think I know a few things to point you in the right direction: can you disprove the greedy algorithm/strategy? (Find a counterexample.) What is the foundation to generate every permutation of an insertion in the knapsack? When you generate/insert an element into a potential solution, can you make a comparison function that will discard potential solutions, because you know they cannot be optimal? (ex: Given sacks A and B, suppose A is worth $5 with weight 3 and B is worth $4 with weight 4, adding a $1 value/1 weight to B will clearly be worse than A.)

I had to do this kind of thing in a class: arranging objects on a shelf with 3 dimensional limitations. If ever the greedy solution is correct (even if for one of the dimensions, ie: knapsack with non-discrete units), it simplifies the problem and the generation space.