Question: [ 1 point ] Huffman::ascii _ decompress _ body ( ) : This function should read one bit ( a ' 0 ' or '

[1 point]Huffman::ascii_decompress_body(): This function should read one "bit" (a '0' or '1' char) at a time from the input stream until a legal code is assembled, then write the corresponding decoded character to the output stream, and repeat until reaching the end of file
[2 points]Huffman::build_optimal_trie(): This function should create a forest of one-node tries (akatrie_pq) representing the characters in the input file and their frequencies, then repeatedly combine the two smallest tries until only one is left according to the following instructions:
1. Remove trie intrie_pqwith SMALLEST frequency, assign tofirst, remove trie in PQ with NEXT SMALLEST frequency, assign tosecond2. Create newTrieNodeand makefirstandsecondits left and right children, respectively. Set new node's frequency to the sum offirstandsecond's frequencies, and then put the whole thing back into the priority queue
[2 points]Huffman::compute_all_codes_from_trie(): The function should recursively traverse the trie rooted atTto determine thehuffcodestring at every leaf and initializecompression_mapanddecompression_mapwith this information

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!