(Last Revision: 11/17/96) ////////////////////////////////////////////////// CS 3100 PROGRAMMING ASSIGNMENT #05 -- HUFFMAN CODE ASSIGNMENT ////////////////////////////////////////////////// +++++++++++++++++++++++++++++++++++++++++++++ Level Two Program DUE Wednesday, November 27. Finished Program DUE Friday, December 06. +++++++++++++++++++++++++++++++++++++++++++++ You will write a program that 1. reads an input file of 66 or fewer lines, each line consisting of 80 or fewer characters. 2. calculates and records the frequencies of each (printable ascii) character, plus the frequency of the end of line "flag", 3. builds a Huffman code tree and encoding table based on the character and flag frequencies found, 4. uses the encoding table to write the encoded version of the input file to an output file called "coded", and 5. uses the Huffman tree to decode the "coded" file created in step 4, putting the decoded message in a file called "decoded". DETAILS Your program must read from standard input, so that if the desired input file is called "foo" and the compiled program is called "a.out", then I can get your program to read from foo by typing a.out < foo on the command line. To simplify matters, you will write 0's and 1's to the "coded" file instead of 0 and 1 bits. The file "decoded" is supposed to be identical to the input file, because it will have been been created by encoding, and then decoding, the contents of the input file. You may have to handle end-of-line markers in the input carefully, to make sure that the carriage returns can be placed into the "decoded" file in the right places. You will design all the data structures for this program. You will be expected to come up with an "elegant" solution to the problem -- i.e. a solution that does a reasonable job of simultaneously employing a simple algorithm and economizing on the use of code, time, and memory. You can read about Huffman codes on pages 315-319 in Stubbs and Webre. Since this file itself has fewer than 67 lines, and since all the lines are shorter than 81 characters, it could be used as the input file to the program!