retagged by
13,013 views
32 votes
32 votes

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?

$110111100111010$

  1. $fdheg$
  2. $ecgdf$
  3. $dchfg$
  4. $fehdg$
retagged by

2 Answers

Best answer
47 votes
47 votes

Answer is A. Huffman's tree is as follows. The two least frequent characters are taken as the children of a newly made node and the frequency of the newly made node is made equal to the sum of those two child nodes. Then the same procedure is repeated till all nodes are finished. 

$110111100111010 = 110\;11110\;0\;1110\;10 = fdheg$

edited by
6 votes
6 votes

we apply greedy algorithm on the frequencies of the characters to generate the binary tree.Assigning 0 to the left edge and 1 to the right edge.

prefix codes for the characters are...

a – 1111110
b – 1111111
c – 111110
d – 11110
e – 1110
f – 110
g – 10
h – 0

Given String can be decomposed as fdheg.

Answer is A.

Answer:

Related questions

29 votes
29 votes
2 answers
1