Data Structures & AlgorithmsHardGATE CS · CAT · MBA placement

Items as (weight, value) are [(10, 60), (20, 100), (30, 120)]. You may take any FRACTION of an item. The capacity is 50. What is the maximum total value? (Give the exact value; it may be fractional.)

  1. A. 220
  2. B. 240
  3. C. 280
  4. D. 244

Correct answer: B. 240

Fractional knapsack: sort by value per weight (60/10 = 6, 100/20 = 5, 120/30 = 4), take whole items while they fit and a fraction of the next one. The 0/1 version cannot split items, so it gives a smaller value here.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic