CS301- Data Structure
V irt u a I U n ive rs ity
Assignment No.2 Solution Total marks = 20
. Semester: Spring 2024 Deadline
24th of Jun 2024
Please carefullv read the following instructions before attemntine the assignment Solution.
NOTE
Don't copy-paste the same
answer.
Make sure you can make some changes to your solution file before submitting
copy paste solution will be marked zero.
If you found any mistake then correct yourself and inform me.
Before submitting an Assignment GDB checks your assignment requirement file.
For any query, feel free to Contact at
WhatsApp: +923074960034
Provide by M.JUNAID QAZI
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.
String: “Data Structures is one of the core courses of BS(CS) program.”
Note: Double quotes are not the part of string.
a. Build frequency table and Huffman encoding tree. [14 Marks]
Use the following sample frequency table:
Character D a t S r u c e s i o n f h B ( C ) p g m Spac
e
Frequenc 1 3 4 3 6 3 3 5 4 1 6 1 2 1 1 1 1 1 1 1 1 10 1
Y
CONTACT ON WHATSAPP
+923074960034
Number 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
of Bits
used
without
any
encoding
Huffman
code of
each
character
Number
of Bits
used with 6 15 16 15 24 15 24 20 16 6 24 6 10 6 6 6 6 6 5 5 5 20 5
Huffman
encoding
Huffman encoding tree
b. Calculate how many bits will be used for the above string: [6 Marks]
Without using any encoding technique
Answer: Number of bits without any encoding technique = 61*8= 488 bits
With Huffman encoding technique
Answer: Number of bits by using Huffman encoding technique = 267 bits
What percentage of bits is saved by Huffman encoding scheme?
Answer: Percentage = ((488-267) / 488) * 100 = 45.28%
Every Assignment/GDB is change due to unique Student ID so don’t copy
That is truly perfect step by step idea solution get help easily.
Wish you the very best ofLucki
CONTACT ON WHATSAPP
+923074960034