CS301_Assignment-2
CS301_Assignment-2
02
Name: Nabeel Ahmed
SEMESTER Spring 2024
CS301- Data Structures ID: BC230428531
Consider the following string saved into a string type variable. We want to send it over the network to another
computer. Use the given string and answer (solve) the questions given below.
Character D a t Space S r u c e i s o n f h B ( C ) p g m .
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 8 24 32 80 24 48 24 24 40 8 32 48 8 16 8 8 8 8 8 8 8 8 8
of Bits
used
without
any
encoding
Huffman
100110
11111
0111
110
0100
000
0101
0110
1110
100111
1000
001
101000
10010
101001
101010
101011
101100
101101
101110
101111
111100
111101
code of
each
character
Number
of Bits
used with 6 15 16 30 12 18 12 12 20 6 16 18 6 10 6 6 6 6 6 6 6 6 6
Huffman
encoding
b. Calculate how many bits will be used for the above string: