Programming Assignment 3 Computer Science 102

Spring 2009

Due APR 27 MON 11:59pm .

the final will be MON MAY 11 2:00 pm in rm 102 WWH


In Draft #3 we will decode using an instance of HashMap.

Draft #3

Here are the methods of your draft #2 to be altered:

  1. public void printCode(Map hash) is passed an instance of HashMap that is instantiated in the main method. Please do this in a "lint-free" way.

  2. private void printCode(TreeNode tree, String s, Map hash) is altered to accomodate hash an instance of HashMap. It is a recursive routine as in draft #2 but now it also places the Huffman code as the key and the letter associated with it in a hash table using hash.put.

  3. Method public String decode(Map hash) reads the compressed file "huffcode.txt" and forms a key by concatenating the "bits", sending them to the hash table until a non-null value is obtained. When this happens a letter is retrieved from the table and the key is initialized so that another letter can be retrieved.

Each procedure should contain preconditions and postconditions. The data for this program is the same as for drafts #1 and #2.

Your main method should be altered so that it: