Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task For this project, you have been provided an implementation of the Huffman tree con struction algorithm (DO NOT modify this code. It is possible
Task For this project, you have been provided an implementation of the Huffman tree con struction algorithm (DO NOT modify this code. It is possible to construct multiple Huffman trees with the same message if num same frequency value. The construct function that I set up ensures that your Huff man tree will produce results consistent with the test cases used for grading). This algorithm utilizes a templated min heap class that you must implement. You must also implement a function that prints the Huffman encoding of message using the Huffman tree constructed from the same message. Specifically, you must implement the following functions: erous charac ters in the message share the void MinHeap: :insert (const T data, const int key) Insert the provided user data into the min heap using the provided key to make comparisons with the other elements in the min heap To ensure that your min heap produces consistent results, stop bubbling up a child node if it shares the same key value as its parent node T MinHeap: :extract min() Remove from the min heap the element with the smallest key value and return its data. If you come across two sibling nodes that share the same key value while sifting down a parent node with a larger key value, then you should swap the parent node with the left child to ensure that your min heap produces consistent results. T MinHeap: :peek const: Retrieve the minimum element in the min heap and return its data to the user Do not remove this element from the min heap in this function. void MinHeap: :size) const: Return the size of the min heap void HuffmanTree: :print() const: Print the Huffman encoding of the member variable message assigned in the construct function
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started