Question: This a C++ problem. Thank you so much!! Huffman Code Trees CS101 Project 4 Due 11/21 You are to write a program that reads a

This a C++ problem. Thank you so much!!This a C++ problem. Thank you so much!! Huffman Code Trees CS101Project 4 Due 11/21 You are to write a program that readsa plain text file, computes a Huffman code tree for that text

Huffman Code Trees CS101 Project 4 Due 11/21 You are to write a program that reads a plain text file, computes a Huffman code tree for that text file, and writes out the encoded version of the text. Your program should read the text from the file given as a command-line argument. You should compute the number of occurrences of each character in the file, and each character (and its frequency) should be placed in a new tree node You should build a min-heap containing these nodes Build the Huffman Code Tree using the heap. As you create new internal nodes, give them a unique character label, using extended ASCII characters, starting with character 128 Write the pre-order traversal followed by the in-order traversal of the Huffman code tree to the file "tree.txt". Write the ASCII value for each node in the traversal. The internal nodes will have ASCII values greater than 127 and the leaves will have values less than 128. The two traversals should be separated by a newline Construct a table containing the encoding for each character, storing the encoding as a string Encode the original text, writing the encoded version to "code.txt". This file should be ASCII 0, and T characters (much easier to debug) * * * (for 5 bonus points) also create a true binary version of the encoded text, writing it to "code.bin". In the binary file, use the first two bytes to indicate the number of characters in the text. If the last character doesn't finish a byte then pad the last byte with 0's Huffman Code Trees CS101 Project 4 Due 11/21 You are to write a program that reads a plain text file, computes a Huffman code tree for that text file, and writes out the encoded version of the text. Your program should read the text from the file given as a command-line argument. You should compute the number of occurrences of each character in the file, and each character (and its frequency) should be placed in a new tree node You should build a min-heap containing these nodes Build the Huffman Code Tree using the heap. As you create new internal nodes, give them a unique character label, using extended ASCII characters, starting with character 128 Write the pre-order traversal followed by the in-order traversal of the Huffman code tree to the file "tree.txt". Write the ASCII value for each node in the traversal. The internal nodes will have ASCII values greater than 127 and the leaves will have values less than 128. The two traversals should be separated by a newline Construct a table containing the encoding for each character, storing the encoding as a string Encode the original text, writing the encoded version to "code.txt". This file should be ASCII 0, and T characters (much easier to debug) * * * (for 5 bonus points) also create a true binary version of the encoded text, writing it to "code.bin". In the binary file, use the first two bytes to indicate the number of characters in the text. If the last character doesn't finish a byte then pad the last byte with 0's

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 Databases Questions!