CS301 Assignment 3 Solution
CS301 Data Structures Assignment 3 Complete Solution

Objective
The objective of this assignment is,
o[font=Times New Roman]  [/font]To make you familiar with concept of Huffman Encoding.

Question 1:
While transmission through network, it is always important to keep data transmission rate high so data over the network can be increased using two ways; either increases the bandwidth of communication channel or decrease the size of data (compression) to increase the bandwidth utilization.
Lossless data compression algorithms are important in network and Huffman encoding scheme can be used for lossless data compression. Suppose the following string is being transmitted over the network:

Data Compression in data structure

We cannot increase the bandwidth of communication channel. Instead we have to compress the given string. Use Huffman encoding scheme to encode the given string.

Solution
To encode the string:

1. Build a table containing the following information about the string. 2. Build Huffman encoding tree. The tree will be built with the help of characters and their respective frequencies which you will find in step 1.
Huffman Tree If you did not understood any step or have any questions regarding Huffman Encoding or the assignment, post below in the comments.

Good luck!
How to solve Part 3?
3. Calculate how much bits are consumed by original and compressed string. What percentage of bits is saved by Huffman encoding scheme?
(01-20-2017, 11:44 AM)Lahori Wrote:  How to solve Part 3?
3. Calculate how much bits are consumed by original and compressed string. What percentage of bits is saved by Huffman encoding scheme?

For part 3, calculate number of bits of the string in ASCII code and then calculate number of bits of the string using Huffman Encoding, and then you'll have to tell what percentage you save by using Huffman encoding.
please explain 3rd part clearly i m so much confuse in this ASCII and huffman
(01-20-2017, 12:26 PM)hafsarana Wrote:  please explain 3rd part clearly i m so much confuse in this ASCII and huffman

In ASCII code we need 8 bits to represent every character. So for example if there are 50 characters, total number of bits required to send this string will be 50x8 = 400
Now in Huffman code, you will get different number of bits for different characters, the characters with the most frequency will need the least amount of bits as they will have the shortest Huffman code associated with them.
In this assignment you will need to calculate the sum of all those bits, lets suppose the sum of all Huffman code bits is equal to 100.
To calculate percentage, 100/400 * 100 = 40% which means you are saving 60% of the data by using Huffman encoding.

Hope this cleared it for you.
(01-20-2017, 03:55 PM)Rana Wrote:
(01-20-2017, 12:26 PM)hafsarana Wrote:  please explain 3rd part clearly i m so much confuse in this ASCII and huffman

In ASCII code we need 8 bits to represent every character. So for example if there are 50 characters, total number of bits required to send this string will be 50x8 = 400
Now in Huffman code, you will get different number of bits for different characters, the characters with the most frequency will need the least amount of bits as they will have the shortest Huffman code associated with them.
In this assignment you will need to calculate the sum of all those bits, lets suppose the sum of all Huffman code bits is equal to 100.
To calculate percentage, 100/400 * 100 = 40% which means you are saving 60% of the data by using Huffman encoding.

Hope this cleared it for you.
bro, clearly give us the solution of 3rd point as today is last date

bro, clearly give us the solution of 3rd point as today is last date
(01-20-2017, 05:55 PM)wasim_288 Wrote:
(01-20-2017, 03:55 PM)Rana Wrote:
(01-20-2017, 12:26 PM)hafsarana Wrote:  please explain 3rd part clearly i m so much confuse in this ASCII and huffman

In ASCII code we need 8 bits to represent every character. So for example if there are 50 characters, total number of bits required to send this string will be 50x8 = 400
Now in Huffman code, you will get different number of bits for different characters, the characters with the most frequency will need the least amount of bits as they will have the shortest Huffman code associated with them.
In this assignment you will need to calculate the sum of all those bits, lets suppose the sum of all Huffman code bits is equal to 100.
To calculate percentage, 100/400 * 100 = 40% which means you are saving 60% of the data by using Huffman encoding.

Hope this cleared it for you.
bro, clearly give us the solution of 3rd point as today is last date

From above diagram, the number of bits used by Huffman code is = 55, now to calculate percentage, divide 55 by original number of bits with ASCII code i.e = 272, it results as 0.2022, multiplying with 100 gives 20.22%
i need complete  file solution of cs301 as soon as posible
(01-20-2017, 07:49 PM)sidra husnain Wrote:  i need complete  file solution of cs301 as soon as posible

Complete solution is posted here. No point in submitting someone else's file, you just have to make your file from the solution posted here. Do it yourself so you get the maximum marks.
If you do not understand anything, then feel free to ask.

Thread / Author Replies Views Last Post
Last Post by Queencumn
09-14-2021, 12:42 AM
09-12-2021, 08:02 PM
Last Post by Ayra Suleman
01-25-2020, 11:33 PM
Last Post by Ayra Suleman
08-01-2019, 10:24 PM
Last Post by Ayra Suleman
07-26-2019, 06:59 PM
Last Post by Mishi Khan
06-01-2019, 01:11 AM
Last Post by Mishi Khan
05-28-2019, 01:57 AM