GATE | GATE IT 2006 | Question 48
The characters a to h have the set of frequencies based on the first 8 Fibonacci numbers as follows
a : 1, b : 1, c : 2, d : 3, e : 5, f : 8, g : 13, h : 21/
A Huffman code is used to represent the characters. What is the sequence of characters corresponding to the following code?
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.
Background Required – Generating Prefix codes using Huffman Coding.
First we apply greedy algorithm on the frequencies of the characters to generate the binary tree as shown in the Figure given below. Assigning 0 to the left edge and 1 to the right edge, prefix codes for the characters are as
a – 1111110
b – 1111111
c – 111110
d – 11110
e – 1110
f – 110
g – 10
h – 0
Given String can be decomposed as
110 11110 0 1110 10
f d h e g
This solution is contributed by Pranjul Ahuja .
Quiz of this Question