GATE Computer ScienceVery hardGATE CS (PYQ pattern)

The fractional knapsack greedy algorithm (taking items by value/weight ratio, the last one fractionally) is run on capacity 26 and items (weight, value): (12, 24), (7, 13), (11, 23), (8, 15), (9, 16), (6, 11). By how much does its optimal value exceed the optimal 0/1 knapsack value of this instance?

  1. A. 1.625
  2. B. 1.5
  3. C. 0.625
  4. D. 2.625

Correct answer: A. 1.625

Ratios: 23/11 = 2.09, 24/12 = 2, 15/8 = 1.875, ...: take (11, 23) and (12, 24) fully (weight 23), then 3/8 of (8, 15) = 5.625, total 52.625. The 0/1 optimum is 51, so the gap is 1.625.

More Algorithms questions

Exams that ask this topic