Home
VU Past Papers
_Final Term Past Papers
_Mid Term Past Papers
VU Assignments Solution
CV Templates
Essay
Application Form Samples
Privacy Policies
Home
VU Assignments
CS301 Assignment No 3 Solution File Download 2020
CS301 Assignment No 3 Solution File Download 2020
Abubakar Afzal
January 21, 2020
CS301 Assignment No 3 Solution File Download 2020
CS301 Assignment No 3 Solution File Download 2020
CS301 Assignment No 3 Solution File Download 2020
CS301 Assignment No 3 Solution File Download 2020
Copy Solution Code.. Got to End of page.
/*CS301 Assginment 3 Fall 2019 Create Name: Abubakar Afzal Student ID: bc1234567*/ //Solved by: Stshine.blogspot.com #include
using namespace std; class HeapNode_Min { // Tree node of Huffman public: //Add data members here. char d; unsigned f; HeapNode_Min *l, *r; HeapNode_Min(char d, unsigned f = -1) { //Complete the body of HeapNode_Min function this->d = d; this->f = f ; this->l = NULL; this->r = NULL; } }; class Analyze { // two heap nodes comparison public: bool operator()(HeapNode_Min* l, HeapNode_Min* r) { //add return before statement and statement is completed. return (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(root->r, s + "1"); //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
, Analyze> H_min; int a=0; while (a
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' }; //Complete this statement by passing data type to both sizeof operators int size_of = sizeof(alphabet) / sizeof(*alphabet); cout<<"Alphabet"<<":"<<"Huffman Code\n"; cout<<"--------------------------------\n"; //Call Huffman_Codes function. HCodes(alphabet, frequency, size_of); return 0; }
Copy text
[full_width]
Featured post
Download Virutal University Final Term Past Papers 2023
February 26, 2023
Follow on Social Media
Popular Posts
The Bank of Punjab Latest Management Trainee Program 2021 BOP Galaxy Apply Online
September 29, 2021
Download Virutal University Final Term Past Papers 2023
February 26, 2023
Civilian jobs in Pak Navy Latest 2022
May 20, 2022
Latest Admissions
3/Admission/post-list
Categories
Vu Past Papers
VU Assignments
Essay
Admission
Application
CV Templates
Documents
Vu Soft
Blogger Course
Facebook Cover Photos
Free Course
Tutorials
Join Facebook Page
STshine
Jobs Catagories
AIOU
ASF Jobs
Agency Jobs
Army
Atomic Energy
BISP Jobs
BZU
Bank Jobs
DG Khan
District & Session Judge Muzaffargarh
EDUCATORS JOBS
Education Department
Federal Service Tribunal jobs 2018
Food Department
Fpsc
Funds Scheme
Governments
Heart Department
Imdad Insaf Program
Janbaz Force
Jobs
Medical Jobs
Ministry
Motorway
NLC
NTDC
Navy
Nts
OTS
PAF
PPSC
PTS
Pakistan Rangers
Private
Punjab Police
Railway
Rescue 1122
Revenue Department Jobs
SPU
Tevta
UTS
Vocational Training Council
WASA Jobs
Wapda
ZTBL
airport security force jobs 2018