instance n = 4, (p1, p2, p3,,
p4) =
(10, 10, 12, 18),
(w1, w2, w3, w4) = (2, 4, 6, 9) and M = 15. The maximum profit is given by (Assume
p and w denotes profit and
weight of objects respectively)
(A) 40
(B) 38
(C) 32
(D) 30.
Answer B.
Greedy method.
product
|
Weight
|
price
|
Pi/w1(cost index)
|
P1
|
2
|
10
|
5
|
P2
|
4
|
10
|
2.5
|
P3
|
6
|
12
|
2
|
P4
|
9
|
18
|
2
|
Put first the costliest items in
bag.
P1(2kg) its value is 10.
P2(4 kg) its value is 10.
P3(6 kg) its value is 12.
P4(3kg) its value is 6.
Total weight =15 and it carries
values of worth =38.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.