Computers and Technology

Me with my assigment

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.

#include

using namespace std;

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 * 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, analyze> h_min;

int a=0;

while (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. "");

}

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< < "";

//call huffman_codes function.

return 0;

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 04:30, justbepunky
There is a simple pattern for determining if a binary number is odd. what is it and why does this pattern occur? how many bits would you need if you wanted to have the ability to count up to 1000? how high could you count in binary if you used all 10 of your fingers as bits? (finger up means 1, finger down means 0)
Answers: 3
image
Computers and Technology, 22.06.2019 08:30, ajj3233
On the loan worksheet in cell c9 enter pmt function to calculate the monthly payment for the altamonte springs 2018 facilities loan. ensure that the function returns a positive value and set the reference to cells b5 and b6 as absolute references.
Answers: 2
image
Computers and Technology, 22.06.2019 15:30, tfornwalt4390
Melissa needs to add a topic to an email that she will send to her teacher. choose the name of the field where she should type her topic.
Answers: 2
image
Computers and Technology, 22.06.2019 18:30, lailahussain99
Which of the following is an example of intellectual properly! oa. new version of a novelb. journal of ideasc. pages of a bookood. lines of a poem
Answers: 2
Do you know the correct answer?
Me with my assigment

in the given code we are using two classes and two functions. the f...

Questions in other subjects:

Konu
Physics, 07.01.2020 11:31
Konu
Social Studies, 07.01.2020 11:31
Konu
Physics, 07.01.2020 11:31