Question

Problem (A1) (20 points): Huffman Coding Consider a message having the 5 symbols (A,B,C,D,E) with probabilities (0.1,0.1,0.2

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Data for huffman coding :

Symbols A B C D E
Probabilities 0.1 0.1 0.2 0.2 0.4

Construction Huffman trees :

HUFFMAN TREE 1:

First we find the two symbols with least probabilities that is A and B with 0.1 and 0.1 probabilties. We will call it a combined probability AB. We also place 0 on the left branch and 1 on the right branch. These 0's and 1's will help to construct the Huffman codes. Now we have

A: 0.1 B: 0.1

We will again repeat the previous step, dealing only with remaining Probabilities and combines probabilities. In this case now we have 3 minimum probabilities i.e. C:0.2, D:0.2 and AB :0.2. For this first case of Huffman tree we will select C and D as minimum probabilities to break the tie. Now we have

6.2 EA FA A : 0.1 8 : 0.1 2.ܘ : c 5 : 6.2

After repeating the previous steps a few more times until all the probabilities are used we get

E: 0.4 0.6 0.2

HUFFMAN TREE 2 :

First we find the two symbols with least probabilities that is A and B with 0.1 and 0.1 probabilties. We will call it a combined probability AB. We also place 0 on the left branch and 1 on the right branch. These 0's and 1's will help to construct the Huffman codes. Now we have

A: 0.1 B: 0.1

We will again repeat the previous step, dealing only with remaining Probabilities and combines probabilities. In this case now we have 3 minimum probabilities i.e. C:0.2, D:0.2 and AB :0.2. For this first case of Huffman tree we will select C and AB as minimum probabilities to break the tie. Now we have

C: 0.2 0.2 A :0.1 B : 0.1

After repeating the previous steps until all the probabilities are used we get

E: 0.4 0.6 0:0.2 0. 4 C: 0.2 0.2 A :0.1 B: 0.1

HUFFMAN CODES :

Huffman tree 1 : Huffman tree 2 :

A = 1110     A = 100

B = 1111 B = 101

C = 110 C = 110

D = 10 D = 111

E = 0 E = 0

HUFFMAN AVERAGE CODE LENGTH:

Huffman tree 1 :

If we sum the products of the probabilities and the code lengths for this case we get

0.1 *4 + 0.1 *4 + 0.2 *3 + 0.2 *2 + 0.4 *1 = 2.2

Huffman tree 2 :

If we sum the products of the probabilities and the code lengths (<L> = \tiny \sum_{i=1}^{n} piLi) for this case we get

0.1 *3 + 0.1 *3 + 0.2 *33+ 0.2 *3 + 0.4 *1 = 2.2

hence, the average code length of both the trees are same.

MINIMUM VARIANCE :

Huffman tree 1 :

Calculating variance using the given formula:

1/5 [ 0.1(4 - 2.2)2 + 0.1(4 - 2.2)2 + 0.2(3 - 2.2)2 + 0.2(2 - 2.2)2 + 0.4(1 - 2.2)2 ] = 0.272

Huffman tree 2 :

1/5 [ 0.1(3 - 2.2)2 + 0.1(3 - 2.2)2 + 0.2(3 - 2.2)2 + 0.2(3 - 2.2)2 + 0.4(1 - 2.2)2 ] = 0.192

Second set of Huffman codes (i.e. Huffman tree 2 ) is more preferable because it has minimum variance.

Add a comment
Know the answer?
Add Answer to:
Problem (A1) (20 points): Huffman Coding Consider a message having the 5 symbols (A,B,C,D,E) with probabilities...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT