0% found this document useful (0 votes)
28 views

CS301 Assignment 02

Uploaded by

Aqib Rajput
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

CS301 Assignment 02

Uploaded by

Aqib Rajput
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment No.

02
SEMESTER Spring 2024

CS301- Data Structures

Total Marks: 20

Lectures Covered: 25-26

Due Date: 24th June, 2024

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.

For any query about the assignment, contact at [email protected]

Question. No. 1:
Marks: 20
String:
Data Structures is one of the core courses of BS(CS) program.

a. Build frequency table and Huffman encoding tree.


[14 Marks]

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

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]

 Without using any encoding technique: 488 bits

 With Huffman encoding technique: 251 bits

 Percentage of bits saved by Huffman encoding scheme: 48.57%

You might also like