C-COMP9319-Assignment 1

2021/6/21 COMP9319 2021T2 Assignment 1
https://www.cse.unsw.edu.au/~wong/cs9319-21a1.html 1/3
COMP9319 2021T2 Assignment 1: Entropy
and Size Determination of Huffman & LZW
Encoding
This is a warm-up assignment for you to practise the knowledge that you learned from the
first 2 weeks and to get familiar with the programming tools (e.g., makefile). Your task in
this assignment is to implement a C or C++ program that determines the average number
of bits to encode a given file using static Huffman encoding and LZW as well as its entropy.
The given file can be a text or binary file (e.g., images, videos or executable programs).
When you determine the average number of bits, you assume that the size of the encoded
file should be the minimum size (i.e., do not need to include any overheads such as the size
of any statistic information) and should not consider adding any other encoding / further
optimisation into it.
Your program should be called csize. Your program should accept: 1) an optional
commandline argument -s and a number between 9 and 18 (inclusively) to specify the fixed
width (in bits) of the codes for LZW (where the width determines the number of dictionary
entries available). 2) a path to the given file to be encoded (e.g.,
~/folder1/subfolder2/file2.jpg). If -s is omitted, the default width of 12 bits is assumed.