What is the average length encoding of a letter for a huffman code of these letters and their frequencies: a : 0.15, b : 0.25, c : 0.20, d : 0.35, e : 0.05?

Answers

The average length encoding of a letter for a Huffman code of the letters and their given frequencies will be 245.

We have,

Frequencies:

a = 0.15 = 15,

b = 0.25 = 25,

c = 0.20 = 20,

d = 0.35 = 35,

e = 0.05 = 5,

So,

Now,

According to the question,

We will make Huffman tree,

i.e.

a = 0.15 = 15,

b + c = 25 + 20 = 45

d + e = 35 + 5 = 40,

Now,

a + b + c + d + e = 100

So,

a = 11 = 2 digits

b = 101 = 3 digits

c= 100 = 3 digits

d= 01 = 2 digits

e= 00 = 2 digits

And,

We know that,

Total bits required to represent Huffman code = 12.

So,

Now,

The average code length = a * 2 digits + b * 3 digits + c * 3 digits + d * 2 digits + e * 2 digits

Huffman codeof the letters and their given frequencies will be 245.Huffman code= 12.Huffman codeof the letters and their given frequencies will be 245.Huffman codehere