0

I came across the following question in this course:

Consider a variation of the Knapsack problem where we have two knapsacks, with integer capacities 1 and 2. As usual, we are given items with positive values and positive integer weights. We want to pick subsets 1,2 with maximum total value such that the total weights of 1 and 1 are at most 1 and 2, respectively. Assume that every item fits in either knapsack. Consider the following two algorithmic approaches.

(1) Use the algorithm from lecture to pick a max-value feasible solution 1 for the first knapsack, and then run it again on the remaining items to pick a max-value feasible solution 2 for the second knapsack.

(2) Use the algorithm from lecture to pick a max-value feasible solution for a knapsack with capacity 1+2, and then split the chosen items into two sets 1+2 that have size at most 1 and 2, respectively.

Which of the following statements is true?

  1. Algorithm (1) is guaranteed to produce an optimal feasible solution to the original problem provided 1=2.

  2. Algorithm (1) is guaranteed to produce an optimal feasible solution to the original problem but algorithm (2) is not.

  3. Algorithm (2) is guaranteed to produce an optimal feasible solution to the original problem but algorithm (1) is not.

  4. Neither algorithm is guaranteed to produce an optimal feasible solution to the original problem.

The "algorithm from lecture" is on YouTube. https://www.youtube.com/watch?v=KX_6OF8X6HQ, which is 0-1 knapsack problem for one bag.

The correct answer to this question is option 4. This, this and this post present solutions to the problem. However, I'm having a hard time finding counterexamples showing that options 1 through 3 are incorrect. Can you cite any?

Edit: The accepted answer doesn't provide a counterexample for option 1; see 2 knapsacks with same capacity - Why can't we just find the max-value twice for that.

Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219

1 Answers1

1

(Weight; Value): (3;10), (3;10), (4;2) capacities 7, 3

The first method chooses 3+3 into the first sack, remaining items does not fit into the second one

(Weight; Value): (4;10), (4;10), (4;10), (2:1) capacities 6, 6

The second method chooses (4+4+4) but this set cannot fit into two sacks without loss, while (4+2) and (4) is better

MBo
  • 77,366
  • 5
  • 53
  • 86