GATE | GATE-CS-2017 (Set 2) | Question 58

A message is made up entirely of characters from the set X = {P,Q,R,S,T} . The table of probabilities of each character is shown below :

Gate_6

A message of 100 characters over X is encoded using Huffman coding. Then the excepted length of the encoded message in bits is _____
(A) 225
(B) 226
(C) 227
(D) 228


Answer: (A)

Explanation:



In Huffman coding, we pick the least
two frequent (or probable) character, combine them and create
a new node.

    .08 (T)      0.17(R)    0.19(S)     0.22(P)
      \        /                 \       /
         0.25    0.34(Q)         0.47
           \      /               /
             0.59                /
               \                /
                         1

Looking at above tree structure, Number of bits required by each:
P – 2
Q – 2
R – 3
S – 2
T – 3

Therefore, excepted length of the encoded message

= 3*0.8 + 3*0.17 +  2*0.19  + 2 *0.22 + 2*0.34

= 2.25

For 100 characters, 2.25*100 = 225

Therefore, option A is correct.

 

Quiz of this Question



My Personal Notes arrow_drop_up