A message is sent across a network which is too big and needs
compressing.
The message occurs with the following frequency:- m1 = 30, m2 = 25,
m3 =
15, m4 = 12, m5 = 10 and m6 = 8. Using the Huffman Coding
data
compression algorithm, calculate the average code length in bits
and explain how many bits are required to send the same information
using a fixed
length code.
Answer :
Given, the occurrence frequency of the source message.
Convert it into probability ( dividing the frequency by 100 as
shown in the table below)
Step 1 : construct the Huffman tree.
Step 2 : Traverse the tree and generate the codewords for each source of message.
Step 3 : compute average code length
(It is given by probability * codeword length)
Avg. Code length = 3*0.08 + 3*0.10 + 3*0.12+ 3*0.15 + 2*0.25 +
2*0.30
= 2.45 bits.
Huffman coding uses the greedy method for the purpose of
implementation. It only supports variable length coding.
Huffman coding does not support fixed length codewords for each
source letter. It only allocates codewords to the source letters
based on its frequency / probability of occurrence.
This algorithm allocates shorter length codeword for a source
letters which has a high frequency and a longer length codeword for
a source letters which has less frequency of occurrence.
A message is sent across a network which is too big and needs compressing. The message...