Solve using fractional knapsack:
M=20, n=4
P= (3, 10, 15, 5)
W= (5, 13, 12, 8).
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.
M=20 (total capacity of bag)
N=4 (no of items)
Let’s find Pi/Wi (profit/weight) for each items:
P1/W1=3/5 = 0.60 (O1)
P2/W2=10/13= 0.76(O2)
P3/W3= 15/12 = 1.25 (O3)
P4/W4 = 5/8 = 0.62 (O4)
Where O is object no
Let’s arrange them in order: 1.25 >> 0.76 >> 0.62 >> 0.60
Object taken
profit
weight
Remaining weight
O3
15
12
8
O2
10
13
0
O4
5
8
0
O1
3
5
0
Now,
< O3,(8/13)O2 >