Cosc 2P03 Fall 2017
Bonus Assignment

(Due at start of 2P03 Exam)

Bonus Assignment

This is a bonus assignment and is optional. If completed, it will be worth 4% of your grade.

LZW compression

For this assignment you will be implementing the LZW compressor and de-compressor. Lets not reinvent winzip but concentrate on the algorithm. Consider a data file composed of 0's, 1's, blanks (char 32) and the EOL character. Hence the alphabet is 4 characters in length.


Write a compressor which will compress the data file to a list of integers which represent the encoded file. To aid in the look up of character strings implement a hash table using external chaining. The size of the table will be 301. Consider a code string C composed of characters Ci sequentially numbered where i>=1. Thus the following hash function may be used. Use the ASCII ordinal value.

                  f(C)=SumOf(87*i*ord(Ci)) mod TableSize.


The decompressor will read the integer file and recreate the original data file.

Output

  Print a copy of the code table, after compression and after decompression. Include a copy of the decompressed data file.

Submission Requirements:

Good Luck