Question: 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

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 of the Huffman code tree to the file preorder.txt and the in-order traversal to the file inorder.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. Write unsigned char values using the put(int) method. 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 1 characters (much easier to debug) (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 does not finish a byte then pad the last byte with 0s. Requirements: You should build all the data structures that you use yourself. You must create a binary heap data structure that uses an array and implements insert and extract-min that run in O(lg N) time. Your makefile should build the executable named encode. Zip all of your source code and makefile into a single .zip file for submission. You must use good object based organization, i.e. use classes in an

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!