All mock tests are FREE till 31 December — register to save your progress
Unit 7 · Data Structures and Algorithms Paper 2 CS · December 2022 Shift 1

Directions (Q91–95): For a knapsack problem, P and W are the profits and weights of a set of 7 items:
P = {9, 5, 2, 7, 6, 16, 9}
W = {2, 5, 6, 11, 1, 9, 3}

Find the optimal solution of the fractional knapsack problem when the maximum capacity is 15.

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. 40

Explanation

Profit/weight ratios: item5 6, item1 4.5, item7 3, item6 1.78, item2 1, item4 0.64, item3 0.33. Take item5 (w 1, p 6), item1 (w 2, p 9) and item7 (w 3, p 9), total weight 6, profit 24. Then item6 (w 9, p 16) fills it exactly: weight 15, profit 40.

More Data Structures and Algorithms questions