CS301 Assignment 3 Solution
#1
CS301 Data Structures Assignment 3 Complete Solution

Objective
The objective of this assignment is,
o  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.
[Image: QaX1BNg.jpg]
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[Image: t1EV79x.png]

If you did not understood any step or have any questions regarding Huffman Encoding or the assignment, post below in the comments. 

Good luck!
#2
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?
#3
(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.
#4
please explain 3rd part clearly i m so much confuse in this ASCII and huffman
#5
(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.
#6
(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
#7
(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%
#8
i need complete  file solution of cs301 as soon as posible
#9
(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.
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  CS301 Assignment 3 Solution Pakistani 2 1,248 07-09-2017, 07:13 PM
Last Post: Admin
  CS301 Assignment 2 Solution - Spring 2017 Admin 0 653 05-17-2017, 08:54 PM
Last Post: Admin
  CS301 Current Mid-Term Exam Admin 0 610 12-17-2016, 10:13 AM
Last Post: Admin
  CS301 All Current Final Term Papers 20 August 2016 to 02 September 2016 Rubaisha(Moody Girl) 0 577 08-20-2016, 01:06 PM
Last Post: Rubaisha(Moody Girl)
  CS301 GDB solution Rubaisha(Moody Girl) 0 781 08-09-2016, 09:38 AM
Last Post: Rubaisha(Moody Girl)
  cs301 current paper Nadeem Rana vu 0 646 05-29-2016, 03:42 PM
Last Post: Nadeem Rana vu
  CS301 Midterm solved papers Nadeem Rana vu 0 642 05-12-2016, 02:19 AM
Last Post: Nadeem Rana vu
  CS301 Past Papers by Moaaz Nadeem Rana vu 0 462 05-12-2016, 02:17 AM
Last Post: Nadeem Rana vu
  CS301 Solved Midterm Past Papers Nadeem Rana vu 0 516 05-12-2016, 02:16 AM
Last Post: Nadeem Rana vu
  CS301 Midterm solved papers Nadeem Rana vu 0 952 05-12-2016, 02:11 AM
Last Post: Nadeem Rana vu



Users browsing this thread:
1 Guest(s)