in Algorithms retagged by
10,801 views
29 votes
29 votes

Suppose the letters $a, \,b, \,c, \,d, \,e, \,f$ have probabilities $\frac{1}{2}, \frac{1}{4}, \frac{1}{8}, \frac{1}{16}, \frac{1}{32}, \frac{1}{32}$, respectively. 

Which of the following is the Huffman code for the letter $a, \,b, \,c, \,d, \,e, \,f$?

  1. $0$, $10$, $110$, $1110$, $11110$, $11111$

  2. $11$, $10$, $011$, $010$, $001$, $000$

  3. $11$, $10$, $01$, $001$, $0001$, $0000$

  4. $110$, $100$, $010$, $000$, $001$, $111$

in Algorithms retagged by
10.8k views

1 Answer

38 votes
38 votes
Best answer

Based on the probabilities, we can say the probable frequency of the letters will be 

$16$, $8$, $4$, $2$, $1$, $1$

Now, the Huffman tree can be constructed as follows:

So, A is the answer for $76$.

https://en.wikipedia.org/wiki/Huffman_coding

edited by
by

4 Comments

@Arjun@srestha

Where to put two same weight?. Sir/ma'am i  did not get any information about that but i have seen many example they follow FCFS.

1
1
if (incoming weight  <= existing weight) then place(incoming weight on LEFT)

else place(incoming weight on RIGHT)

@Arjun sir please correct me if wrong.
0
0
Both the tree is correct. Right skewed will match here with the options.
0
0
Answer:

Related questions