Professional Documents
Culture Documents
Find the value of maximum profit with the optimal solution of the fractional
knapsack problem.
(A) 31
(B) 40.2
(C) 48.5
(D) None of these
Answer: (C)
Explanation:
Decreasing order of P i /W i is
X1, X4, X3, X5, X2
X1 –> profit = 15 and weight = 2
Including X4 –> profit = 15 + 16 and weight = 2 + 4 = 6
Including X3 –> profit = 40 and weight = 9
Now weight left = 3
Weight of X5 = 6 –> half of X5 can be included.
Profit = 40 + 17/2 = 48.5.
Q2)
Let us consider that the capacity of the knapsack W = 60 and the list of provided
items are shown in the following table −
Answer:
Q3)use Huffman code to find how many bits may be required for encoding
the message ‘mississippi’?
Answer :
alphabet i s p m
frequency 4 4 2 1
Huffman code 1 00 010 011
Smpi (11)
0 1
Spm (7)
I (4)
0 1
S (4) pm(3)
0 1
p (2) m(1)
100
0 1
55 F (45)
0 1
30 25
0 1 0 1
0 1
B (9) A (5)
alphabet f e d c b a
frequency 45 16 13 12 9 5
Huffman 1 000 010 011 0010 0011
code
Answer: C
Answer: a
Answer: a
Answer: d