0 votes
How can we change the greedy knapsack algorithm a little bit to guarantee at least 50% value of optimal?
in Greedy Algorithms by AlgoMeister (1.6k points)

1 Answer

+2 votes
 
Best answer

Solution:

Add a 3rd step to the original algorithm states: Return MAX {the Greedy Algorithms's solution, the most valuable item}.

Claim:

The new 3-steps algorithm guarantees at least 50% value of the optimal solution.

Proof:

  1. Recall items have been sorted by its profit(value/weight). Assume the 2nd step of this solution returns a result includes the first k items (a1,a2...ak), since items cannot be divided, ak is the last item included, and ak+1 is the first item excluded. Therefore, the result of this step will be at least equal to the total value of the first k items. That's RESULT1 = a1 + a2 + ...+ ak.
  2. Consider an alternative - amax, where amax is the most valuable item.  Therefore, RESULT2 = amax >= ak+1.
  3. We choose RESULT = max{RESULT1, RESULT2}
  4. Here comes the cool part. Plus the two in-equations, We have (RESULT1 + RESULT2) = a1 + a2 + ...+ ak + ak+1, which is the total value of the first k+1 items, which is also >= the fractional solution we talked about earlier (because the fractional solution takes at most the (k+1)-th item), and also the fractional solution will be at least equal to the optimal solution of this problem because the fractional solution consume all knapsack's capacity and choose items by its profit in decending order.
  5. So we have: RESULT >= RESULT1, and RESULT >= RESULT2.  That is, we have, 2 * RESULT  >=  RESULT1 + RESULT2 = Value(1,k+1) >= the fractional solution >= the optimal solution. That's 2 * RESULT >= Optimal solution.  That is, RESULT >= 0.5 * Optimal Solution.

I wrote an article contains more details about this problem: Knapsack Problem

by AlgoMeister (648 points)
selected by

Related questions

0 votes
2 answers
0 votes
4 answers
asked Mar 3, 2018 in Greedy Algorithms by jmlitfi AlgoMeister (684 points)
0 votes
3 answers
asked Mar 3, 2018 in Greedy Algorithms by jmlitfi AlgoMeister (684 points)
The Book: Analysis and Design of Algorithms | Presentations on Slideshare | Lecture Notes, etc
...