cs301 Assignment No 2
cs301 Assignment No 2
Character D a t Spac S r u c e i s o n f h B ( C ) p g m .
e
Frequency 1 3 4 10 3 6 3 3 5 1 4 6 1 2 1 1 1 1 1 1 1 1 1
Number of 8 24 32 80 24 48 24 24 40 8 32 48 8 16 8 8 8 8 8 8 8 8 8
Bits used
without any
encoding
100110
11111
0111
110
0100
000
0101
0110
1110
100111
1000
001
101000
10010
101001
101010
101011
101100
101101
101110
101111
111100
111101
Huffman code
of each
character
Number of
Bits used with
Huffman
6 15 16 30 12 18 12 12 20 6 16 18 6 10 6 6 6 6 6 6 6 6 6
encoding
Question no 2: Calculate how many bits will be used for the above string:
1. Without using any encoding technique = 488 bits
2. With Huffman encoding technique = 251 bits
3. What percentage of bits is saved by Huffman encoding scheme?
Percentage = (Fixed length bits – Encoding bits ÷ Fixed Length bits) * 100
((488 - 251) ÷ 488) * 100 = 48.56% bits saved