CS301 - Assignment - 02 Done
CS301 - Assignment - 02 Done
Lectures Covered:25-26
Assignment No. 02
SEMESTER Spring 2024 Due Date: 24th June,
2024
CS301- Data Structures
Question. No. 1:
Marks: 20
String:
Data Structures is one of the core courses of BS(CS) program.
Frequency Table
Character Frequency Number of Bits Huffman code of Number of Bits
used without any each character used with
encoding Huffman
encoding
D 1 8 100100 6
a 3 24 0010 12
t 4 32 1000 16
10 80 111 30
S 3 24 0011 12
r 6 48 010 18
u 3 24 11001 15
c 3 24 0110 12
e 5 40 1101 20
s 4 32 1010 16
i 1 8 011100 6
o 6 48 000 18
n 1 8 101111 6
f 2 16 10110 10
h 1 8 101110 6
B 1 8 100111 6
( 1 8 100110 6
C 1 8 011111 6
) 1 8 011110 6
p 1 8 110001 6
g 1 8 110000 6
m 1 8 011101 6
. 1 8 100101 6
Huffman Encoding Tree
The Huffman encoding tree is built by merging nodes with the lowest frequencies until a single
tree is formed.
b. Calculate how many bits will be used for the above string:
[6 Marks]