UGC-NET Jun 2014 · Asymptotic Analysis & Recurrences

MCQ · 2 marks · Problem PROG-DIVC-0038

Consider the fractional knapsack instance $n = 4, (p_{1} , p_{2} , p_{3} , p_{4} ) = (10, 10, 12, 18), (w_{1} , w_{2} , w_{3} , w_{4} ) = (2, 4, 6, 9)$ and $M = 15$. The maximum profit is given by (Assume $p$ and $w$ denotes profit and weight of objects respectively)
  1. A
    $40$
  2. B
    $38$
  3. C
    $32$
  4. D
    $30$

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solutionGreedy by profit per unit weight is optimal for the fractional knapsack.\[\frac{p}{w}:\ \ \frac{10}{2}=5,\ \ \frac{10}{4}=2.5,\ \ \frac{12}{6}=2,\ \ \frac{18}{9}=2.\]Take object 1 (weight 2, profit 10) and object 2 (weight 4, profit 10): used 6, profit 20. Remaining capacity 9; objects 3 and 4 both give 2 per unit, so any 9 units of them add \(9\times2=18\) (e.g. all of object 4).\[\text{Maximum profit}=20+18=38.\]Answer: B

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com