Last Updated : 21 Dec, 2018

Consider the following instances of knap-sack problem:

Item Weight(in Kgs) Value(in $)
1 3 10
2 2 25
3 2 20
4 5 15
5 7 40
6 4 36


Maximum weight of knapsack is 10 Kg. What will be the maximum profit with the optimal solution of the 0/1 knapsack problem?

(A) 101
(B) 96
(C) 92.42
(D) 81


Answer: (D)

Explanation: Knapsack Instance with value / weight:

Item Weight Value Value / weight
1 3 10 3.33
2 2 25 12.5
3 2 20 10
4 5 15 3
5 7 40 5.71
6 4 36 9

Decrersing order of value/weight:

Item Weight Value Value / weight
2 2 25 12.5
3 2 20 10
6 4 36 9
5 7 40 5.71
1 3 10 3.33
4 5 15 3

Now start filling the sack-
item 2 fully:
left weight = 10 – 2 = 8
item 3 fully:
left weight = 8 – 2 = 6
item 6 fully:
left weight = 6 – 4 = 2
So, only P2, P3, and P6 are chosen. Now no other item can be filled in because it is a 0/1 knap sack.
Total profit = 25 + 20 + 36 = 81.

So, option (D) is correct.


Quiz of this Question


Share your thoughts in the comments