Question 25
25. A text is made up of the characters A, B, C, D, E each occurring with the probability 0.08, 0.40, 0.25, 0.15 and 0.12 respectively. The optimal coding technique will have the average length of :
Answer : (4) 2.15 Previous | Next |
UGC NET CS 2018 July - II Question 24 | UGC NET CS 2018 July - II Question 26 |
Given:
Probability for occurrence of each character in text.
A → 0.08
B → 0.40
C → 0.25
D → 0.15
E → 0.12
Now, we apply the Huffman optimal coding technique.
First we have sort the character by the probability of the occurrence in text.
A → 0.08
E → 0.12
D → 0.15
C → 0.25
B → 0.40
We will draw a Huffman tree:
Now Huffman coding for character:
A = 1110
B = 0
C = 10
D = 110
E = 1111
Now, length for each character = no of bits * frequency of occurrence:
Length of A = 4 * 0.08 = 0.32
Length of B = 1 * 0.4 = 0.4
Length of C = 2 * 0.25 = 0.5
Length of D = 3 * 0.15 = 0.45
Length of E = 4 * 0.12 = 0.48
Now add these length to find average length:
Average length = 0.32 + 0.4 + 0.5 + 0.45 + 0.48
= 2.15
So, option (4) is correct.