Programming Assignment 3 Computer Science 102

Spring 2008

Due APR 30 WED 11:59pm .

the final will be MON MAY 12 2:00 pm in rm 109 WWH


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

Draft #4

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

  1. public static 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 static 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 #3 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 static 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 #2 and #3.

Your main method should be altered so that it: