CS301 Assignment 2
CS301 Assignment 2
Charact D a t spa S r u c e i s o n f h B ( C ) p g m .
er
ce
Frequen 1 3 4 10 3 6 3 3 5 1 4 6 1 2 1 1 1 1 1 1 1 1 1
cy
Number
of Bits
used 8 2 3 80 2 4 2 2 4 8 3 4 8 1 8 8 8 8 8 8 8 8 8
without 4 2 4 8 4 4 0 2 8 6
any
encodin
g
Huffma
100110
11111
0111
110
0100
000
0101
0110
1110
100111
1000
001
101000
10010
101001
101010
101011
101100
101101
101110
101111
111100
111101
n code
of each
characte
r
Number
of Bits
used
with
6 5 4 3 4 3 4 4 4 6 4 3 6 5 6 6 6 6 6 6 5 6 6
Huffma
n
encodin
g
b. Calculate how many bits will be used for the above string: [6 Marks]
Without using any encoding technique:
Total no. of frequency x number of bit = 61 x 8 = 488
With Huffman encoding technique :
sum of all bits used with Huffman encoding = 251
What percentage of bits is saved by Huffman encoding scheme?
Fixed length of bits – encoding bits / fixed length bits) x 100 = 48.56% saved