CSCI 2226 and 6620 Data Structures Program 2: Huffman Compression, Phase I Solution.ZIP

CSCI 2226 and 6620 Data Structures Program 2: Huffman Compression, Phase I Solution

1 Goals of this Assignment
In this assignment you will:
1. Write and use a C++ class.
2. Organize a modular program in the C/C++ world.
3. Use a utility module provided by the instructor.
4. Write the rst of several phases of a le compression program that we will develop throughout the term.
2 Huffman Codes
A Huffman code can be used to compress a le. It replaces xed-size, one-byte characters by variable-length codes (strings of bits). The codes for the most frequently used characters will be shorter than 8 bits, those for unusual characters will be longer. No codes are generated for characters that are not
used. The input le is read twice, once to generate the code, then again to encode the le. In this assignments, you will analyze the frequencies of the characters that appear in a text le that will, eventually, be compressed.
2.1 The Initial Tally
1. Create a simple class named Tally. Data members should include an array of 256 integer counters, for tallying occurrences of the 256 possible ASCII characters, a counter for the number of input characters, and an ifstream& for the input le. De ne a constructor, a print function, and a \worker" function named doTally.
2. Write a main program that calls banner() at the beginning. Open the input le and use the open stream as a parameter to instantiate the Tally class. Call doTally(). Print the results of the tally. Call bye() and end.
Powered by