Computer Science EngineeringVery hardISRO SC (CS)

Fractional knapsack: weights [10, 4, 12, 3], values [20, 40, 14, 35], capacity 18. The maximum total value (rounded to the nearest integer) is:

  1. A. 98
  2. B. 96
  3. C. 99
  4. D. 93

Correct answer: B. 96

Sort by value/weight, take whole items then a fraction of the next: 96.17. (Greedy by raw value gives 96.17.)

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic