Algorithms Tick 2 2023

Algorithms Tick 2*: file compression

TL;DR

Augment your unstarred-tick submission to compress and decompress actual files. The compressed file must include the Huffman code needed to decompress it.

Details

Rename your huffman.py as huffmanf.py. Make it accept an option and a filename on the command line.

If the command-line option -e is supplied, huffman-encode the file to a new file. When doing so, include all necessary decoding information to the encoded file (the mapping between codewords and symbols, as well as the original filename), so that the supplied file is self-contained and can be decoded without having access to the HuffmanCode object that generated it. In other words, you must also define a compact and unambiguous specification for “your” Huffman-encoded files, and implement it.

If the command line option -d is supplied, write out the decoded file.

No extra course credit will be awarded for the completion of any optional extras.

What to do