HuffmanCoding-2
HuffmanCoding-2
File f has one million characters. Only a, b, c, d, e, f chars come in the file.
Assume frequency of occurrence of a, b, c, d, e, f is 45%, 13%, 12%, 16%,
9%, 5% . Determine:
a) Huffman Code for each character
b) Calculate bits saved
c) Average code length
Frequency of occurrence of a, b, c, d, e, f is 45%, 13%, 12%, 16%,
9%, 5%
Character Probability Fixed length HuffmanBin |Binarycode|
code arycode
a 0.45 000 0 1
Characters a e i o u s t
Frequency 10 15 12 3 4 13 1
Huffman Code for each character is:
a = 111
e = 10
i = 00
o = 11001
u = 1101
s = 01
t = 11000
Try this!
A networking company uses a Huffman compression technique to encode
the message before transmitting over the network. Consider the following
characters with their frequency: Character Frequency
D 18
A 37
T 29
S 50
R 17
U 30
C 6
E 13
a) Show stepwise a tree that Huffman’s greedy algorithm could produce for
these characters.
b) Encode the message “DATASTRUCTURES” before transmitting on a
network.
c) If the codeword for character “C” is reversed, will there be any effect on
decoding the message at receiver. Justify your answer with example.