CS 301 Assignment No 3 Solution Fall 2019 -VU StudySolution
StudySolution
  • Assignment Solution
    • AIOU Assignment Solutions
    • VU Assignment Solutions
  • Books and Notes
  • Results
  • Past Papers
  • Jobs
    • Latest Govt Jobs
    • Latest Private Jobs
  • Blogs
    • Local Blog
    • International Blog
  • News
    • Health News
  • Test Preparation
No Result
View All Result
  • Assignment Solution
    • AIOU Assignment Solutions
    • VU Assignment Solutions
  • Books and Notes
  • Results
  • Past Papers
  • Jobs
    • Latest Govt Jobs
    • Latest Private Jobs
  • Blogs
    • Local Blog
    • International Blog
  • News
    • Health News
  • Test Preparation
No Result
View All Result
StudySolution
No Result
View All Result

CS 301 Assignment No 3 Solution Fall 2019

admin by admin
December 2, 2020
in VU Fall Assignment Solution
0
0
SHARES
144
VIEWS
Share on FacebookShare on Twitter
Contents hide
1 Related articles
2 CS 604 Assignment NO 3 Solution Fall 2020
3 CS 608 Assignment NO 3 Solution Fall 2020
4 CS 301 Assignment No 3 Solution Fall 2019
5 Note: Check Your Self If U Found Any Mistake Then Comment Here. We will Updated Soon:
6 Solution Updated,Now U Can Check Again For Mistake any Comment Here.
6.1 Make Some Changing before Submit.

Related articles

CS 604 Assignment NO 3 Solution Fall 2020

CS 604 Assignment NO 3 Solution Fall 2020

February 5, 2021
CS 608 Assignment NO 3 Solution Fall 2020

CS 608 Assignment NO 3 Solution Fall 2020

February 5, 2021

CS 301 Assignment No 3 Solution Fall 2019

In this post I am sharing link of CS 301 Assignment No 3 Solution Fall 2019 of Virtual University (VU). Keep visiting StudySolution for updated assignment solutions.

CS 301 Assignment No 3 Solution Fall 2019

Assignment No. 03

Fall 2019

CS301 – Data Structures

Instructions

Please read the following instructions carefully before solving & submitting assignment:

It should be clear that your assignment will not get any credit (zero marks) if:

o        The assignment is submitted after due date.

o        The submitted assignment is other than C++ file (.cpp).

o        The submitted assignment does NOT open or file is corrupted.

o        The assignment is copied (from other student or ditto copy from handouts or internet).

Uploading instructions

You are required to upload / submit .CPP file.

Use Dev-C++, Version 5.11 or above.

 

 

Objective

The objective of this assignment is ;

 

o   To make you familiar with Huffman Encoding technique.

o   To learn how to write a program for Huffman Encoding in C++.

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

 

GOOD LUCK

 

Problem Statement  
As you know, Huffman Encoding is a technique developed and used for data compression. It is widely used algorithm for JPEG images. Incomplete code of Huffman Encoding is given below. You are required to complete the missing code.

In the given code we are using two classes and two functions. The first class HeapNode_Min will consist of data members and a constructor. The second class Analyze will consist of a function which will compare two heap nodes and will return the result. We are also using display function to print the codes of Huffman tree from the root. HCodes function is used to build a Huffman tree, this function is using two while loops and at the end it calls display_Codes function. In main function we are using two arrays, one for frequency and the second one for alphabets.  We are using size_of variable to store the size of data types after their division. At the end of the main function we will call HCodes function.

 

Note:  Just add the missing code. Don’t change the given code. Instructions are highlighted with red color.

 

// Huffman Coding program in c++

 

#include <bits/stdc++.h>

using namespace std;

[the_ad id=”83882″]

 

class HeapNode_Min { // Tree node of Huffman

 

public:

 

//Add data members here.

 

HeapNode_Min(char d, unsigned f)

{

//Complete the body of HeapNode_Min function

}

};

 

class Analyze {  // two heap nodes comparison

 

public:

bool operator()(HeapNode_Min* l, HeapNode_Min* r)

{

(l->f > r->f); //Complete this statement

}

};

 

void display_Codes(HeapNode_Min* root, string s) // To print codes of huffman tree from the root.

{

if (!root)

return;

 

if (root->d != ‘$’)

cout << root->d << “\t: ” << s << “\n”;

 

display_Codes(root->l, s + “0”);

display_Codes( ); //Complete this statement by passing arguments

 

}

 

 

void HCodes(char data[], int freq[], int s) // builds a Huffman Tree

{

HeapNode_Min  *t,*r, *l ;  // top, right, left

 

 

priority_queue<HeapNode_Min*, vector<HeapNode_Min*>, Analyze> H_min;

 

int a=0;

while (a<s){H_min.push(new HeapNode_Min(data[a], freq[a])); ++a;}

 

 

while (H_min.size() != 1) {

 

l = H_min.top(); H_min.pop();

r = H_min.top(); H_min.pop();

 

t = new HeapNode_Min(‘$’,  r->f + l->f);

 

t->r = r; t->l = l;

 

 

H_min.push(t);

}

 

display_Codes(H_min.top(), “”);

}

 

int main()

{

int frequency[] = { 3, 6, 11, 14, 18, 25 };  char alphabet[] = { ‘A’, ‘L’, ‘O’, ‘R’, ‘T’, ‘Y’ };

int size_of = sizeof() / sizeof(); //Complete this statement by passing data type to both sizeof operators

 

cout<<“Alphabet”<<“:”<<“Huffman Code\n”;

cout<<“——————————–\n”;

 

//Call Huffman_Codes function.

 

return 0;

}

 

Sample Output of the above program is given below.

 

Important Note: Use Dev-C++, Version 5.11 or above.

Deadline: Your assignment must be uploaded/submitted at or before 21-1-2020.

Note: Check Your Self If U Found Any Mistake Then Comment Here. We will Updated Soon: 

 

Solution Updated,Now U Can Check Again For Mistake any Comment Here.

 

Make Some Changing before Submit.

 

Click Here For Solution File

Solution File

ShareTweetShare
Previous Post

ENG 201 Assignment No 2 Solution Fall 2019

Next Post

PAK 301 Assignment No 2 Solution Fall 2019

Related Posts

CS 604 Assignment NO 3 Solution Fall 2020

CS 604 Assignment NO 3 Solution Fall 2020

by admin
February 5, 2021
0

CS 604 Assignment NO 3 Solution Fall 2020 In this post, I am sharing the download link of CS 604...

CS 608 Assignment NO 3 Solution Fall 2020

CS 608 Assignment NO 3 Solution Fall 2020

by admin
February 5, 2021
0

CS 608 Assignment No 3 Solution Fall 2020 In this post, I am sharing the download link of CS 608...

CS 504 Assignment No 3 Solution Fall 2020

CS 504 Assignment NO 3 Solution Fall 2020

by admin
February 5, 2021
0

CS 504 Assignment No 3 Solution Fall 2020 In this post, I am sharing the download link of CS 504...

MGT 201 Assignment NO 1 Solution Fall 2020

MGT 201 Assignment NO 1 Solution Fall 2020

by admin
February 5, 2021
0

MGT 201 Assignment NO 1 Solution Fall 2020 In this post, I am sharing the download link of MGT 201...

MTH 202 Assignment NO 2 Solution Fall 2020

MTH 202 Assignment NO 2 Solution Fall 2020

by admin
February 5, 2021
0

MTH 202 Assignment NO 2 Solution Fall 2020 In this post, I am sharing the download link of MTH 202...

Load More
Next Post
PAK 301 Assignment No 2 Solution Fall 2019

PAK 301 Assignment No 2 Solution Fall 2019

Subscribe
Notify of
guest
guest
0 Comments
Inline Feedbacks
View all comments

Search Here

Advertisement

Recent Posts

  • Latest Jobs in Pakistan Railways April 2021 Advertisement
  • Punjab Human Organ Transplantation Authority PHOTA Latest Jobs 2021
  • Punjab Police Counter Terrorism Department CTD Latest Jobs 2021
  • NUMS National University of Medical Sciences Latest Jobs 2021
  • Pak Army 301 Spares Depot EME Rawalpindi Latest Jobs 2021

Advertisement

Test Preparation MCQs

General Knowledge MCQs

Computer Science MCQs

Islamic Studies MCQs

Current Affairs MCQs

Pak Study MCQs

English MCQs

Math MCQs

Sponsored

This Website is Protected by DMCA

DMCA.com Protection Status
  • About
  • Contact Us
  • Privacy Policy
  • Terms Of Use
Email: [email protected]

©2019-2021 StudySolution. All Right Reserved

No Result
View All Result
  • Assignment Solution
    • AIOU Assignment Solutions
    • VU Assignment Solutions
  • Books and Notes
  • Results
  • Past Papers
  • Jobs
    • Latest Govt Jobs
    • Latest Private Jobs
  • Blogs
    • Local Blog
    • International Blog
  • News
    • Health News
  • Test Preparation

©2019-2021 StudySolution. All Right Reserved

  • Get Grammarly Premium at a Very Cheap Price
    BUY NOW
wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply