Last Updated :
31 Oct, 2018
Consider the following characters and their respective frequency:
List-I |
List-II |
e |
4 |
f |
8 |
g |
16 |
k |
32 |
o |
10 |
r |
12 |
s |
18 |
If Huffman coding is used to encode the message, what will be the encoded message for \”geeksforgeeks\”.
(A) 0100000100001100100000000101101000001000011001
(B) 0100000100001100101000001000011001000000001011
(C) 1111111101001011111011110 011010111110111100110
(D) 1011111011110 011011111111010010111110111100110
Answer: (D)
Explanation: Using Huffman coding:
Foloowing are the codes:
k = 0
r = 100
g = 101
s = 110
o = 1110
e = 11110
f = 11111
Code for geeks for geeks: 101 11110 11110 0 110 11111 1110 100 101 11110 11110 0 110
So, option (D) is correct.
Quiz of this Question
Share your thoughts in the comments
Please Login to comment...