0

Last week our teacher gave us a question about Huffman Encoding Algorithm described as below.

HUFFMAN ENCODING ALGORITHM:

  1. Consider all pairs: .
  2. Choose the two lowest frequencies, and make them brothers, with the root having the combined frequency.
  3. Iterate.

The question was to find the Final Binary Tree and Variable Length Codes for the given Alphabets using the above defined Huffman Encoding Algorithm:

A | 10

B | 20

C | 30

D | 40

E | 50

F | 60

I solved the question but my teacher said that I made the wrong tree. Kindly check my answer below and tell me where I am wrong?

MY ANSWER:

Final Binary Tree:

Final binary Tree

Variable Length Code:

Variable Length Codes

Kindly tell me where I am wrong? What wrong I did while making the above Binary Tree?

asked Jan 30, 2018 at 13:12

1 Answer 1

1

Choose the two lowest frequencies, and make them brothers, with the root having the combined frequency.

You did this once for A=10, B=20 for a total of 30, right?

Next you picked C=30, D=40 for a total 70. But there was a better choice, as there are two nodes with score of 30 for a total of only 60. One of them is C=30, and the other? Well, think more dynamically.

answered Jan 30, 2018 at 15:23
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.