Page 1 of 1

Question 2 0 / 40 pts Use the following Support code to answer the questions below: Builds Huffman Tree and decode given

Posted: Sat May 14, 2022 4:19 pm
by answerhappygod
Question 2 0 40 Pts Use The Following Support Code To Answer The Questions Below Builds Huffman Tree And Decode Given 1
Question 2 0 40 Pts Use The Following Support Code To Answer The Questions Below Builds Huffman Tree And Decode Given 1 (18.38 KiB) Viewed 62 times
Question 2 0 40 Pts Use The Following Support Code To Answer The Questions Below Builds Huffman Tree And Decode Given 2
Question 2 0 40 Pts Use The Following Support Code To Answer The Questions Below Builds Huffman Tree And Decode Given 2 (28.01 KiB) Viewed 62 times
Question 2 0 / 40 pts Use the following Support code to answer the questions below: Builds Huffman Tree and decode given input text void InformationSystembulldHuffmaniTree(string text) count frequency of appearance of each character Wand store it in a map unordered_mapchar int> fren: for (char ch text) fregſch]++ 1 1 Part A Question Location a Create a priority queue to store live nodes of W Huffman tree: priority_queue Node", vector<Node>, comppa: W Create a leaf nade for each character and add it W to the priority queue. for auto pair: freq) pa.push(getNode(pair.first, pair second, nullptr. nullptr):

// Part B Question Location // do till there is more than one node in the queue while (pq.size() != 1) { // Remove the two nodes of highest priority // (lowest frequency) from the queue Node "left = pq.top(): pq.pop(); Node "right = pq.top(); pq.pop(); // Create a new internal node with these two nodes // as children and with frequency equal to the sum // of the two nodes' frequencies. Add the new node // to the priority queue. int sum = left->freq + right->freq: pq.push(getNode('sum, left, right));