Huffman Code with Weight

49 Views Asked by At

I am trying to construct a Huffman tree with the symbols $A, B, C, D, E$ with the weights $1, 1.5, 3.1, 3.7, 2.2$.

Now from looking at Huffman coding I order the symbols based on the highest weight like this $D 3.7, C 3.1, E 2.2, B 1.5, A 1$ and paired the lowest weight together.

This is what I constructed and I am looking for feedback I am not sure if it should be the other way around where the lowest weight should be placed first.

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

Given that the OP has now specified they created the tree to minimize the expected weight, I'm entering this answer:

This is a valid Huffman tree, minimizing the expected path weight.