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?

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.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.