Data Structures & AlgorithmsHardGATE CS · Product-company placement

0/1 knapsack with capacity 14: items (weight, value) = (7, 23), (4, 12), (5, 8), (4, 12), (6, 34). What is the maximum total value?

  1. A. 57
  2. B. 58
  3. C. 56
  4. D. 68

Correct answer: B. 58

The DP over capacities gives 58. Greedy by value/weight ratio gives only 57 and greedy by value 57: greedy is optimal only for the fractional version.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic