CS301 Assignment 02
CS301 Assignment 02
02
SEMESTER Spring 2024
Total Marks: 20
Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (marks) if:
The assignment is submitted after due date.
The submitted assignment file is not in .doc or .docx format.
The submitted assignment file does not open or corrupted.
The assignment is copied (from other student or ditto copy from handouts or
internet).
Uploading instructions
Do not wait for grace day. Grace Day is given only if there is problem with LMS on
due date. Submit your solution within due date.
Note that no assignment will be accepted through email if there is any problem in
LMS on grace day.
Objective
The objective of this assignment is
To get hands on practice of constructing frequency table and Huffman encoding tree.
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 Number of Bits
used without of each used with
any encoding character 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
b. Calculate how many bits will be used for the above string:
[6 Marks]