subject

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;

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:10
3. bob is arguing that if you use output feedback (ofb) mode twice in a row to encrypt a long message, m, using the same key each time, it will be more secure. explain why bob is wrong, no matter what encryption algorithm he is using for block encryption (15 points).
Answers: 3
question
Computers and Technology, 22.06.2019 23:20
How can you tell if someone sent you a text message to your email instead of a email
Answers: 1
question
Computers and Technology, 23.06.2019 06:30
You have a small company and want to keep your costs low, but it is important your employees share data. which network would provide you with the most economical solution?
Answers: 1
question
Computers and Technology, 24.06.2019 00:50
3. what is the output of the following statements? temporary object1; temporary object2("rectangle", 8.5, 5); temporary object3("circle", 6, 0); temporary object4("cylinder", 6, 3.5); cout < < fixed < < showpoint < < setprecision(2); object1.print(); object2.print(); object3.print(); object4.print(); object1.set("sphere", 4.5, 0); object1.print();
Answers: 1
You know the right answer?
Me with my assigment

in the given code we are using two classes and two functions. the f...
Questions
question
Mathematics, 29.03.2021 16:00
question
Mathematics, 29.03.2021 16:00
question
Mathematics, 29.03.2021 16:00
question
Mathematics, 29.03.2021 16:00
Questions on the website: 13722360