Question

By applying Huffman’s algorithm construct an optimal binary prefix free code for the following letters A,...

  1. By applying Huffman’s algorithm construct an optimal binary prefix free code for the following letters A, B, I, M,S,X and Z with their corresponding frequencies.

Letter

A

B

I

M

S

X

z

Frequency

12

7

18

10

9

5

2

  1. Construct Huffman Tree by showing all the necessary (5pt)
  2. Give the code-word of each character using the Huffman Tree from (a) (5pt)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Huffman Algorithm to construct optimal binary prefix code for following letters and corresponding frequency..

It Works as follows--

1. put all letters in a Min-Priority Queue.(Q) and create n trees with one tree contain one letter.

2. remove two elements from Q with minimum frequency

, where x= letter with lowest frequency , and y = letter with 2nd lowest frequency.

3. create a new node(z) whose left child is x and right child is y.

set the frequency of z = frequency(x) + frequency(y)

4,Insert the the node z back to the Q.

5.Repeat step 2 to step 4 n-1 times)n is number of letters).

6. Mark  the left edge with binary 0 and right edge with binary 1.

answer to (b)

Now the code-word of a letter is the collection of the binary symbols from root to that letter

so

code-word of letter A is 00

code-word of letter B is 010

code-word of letter I is 10

code-word of letter M is 111

code-word of letter S is 110

code-word of letter X is 0111

code-word of letter Z is 0110

Add a comment
Know the answer?
Add Answer to:
By applying Huffman’s algorithm construct an optimal binary prefix free code for the following letters A,...
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