Optimized Huffman encoder and decoder implementations for SENG 440.
- Clone the repo
git clone https://github.com/isaaccormack/huffman_encoding.git
- Compile the encoder and decoder (-O3 for optimizations)
gcc encode.c -o encode -O3 && gcc decode.c -o decode -O3
- Encode a file and write its encoding to a file
./encode <infile.txt> > encoded.out
- Decode the encoded file to stdout
./decode encoded.out
Tests currently exist for character count, encoding map, and end-to-end encoding & decoding.
In the main
function in encode.c
, ensure only one of the desired tests is uncommented, then recompile encode.c
and run the corresponding test script.
For example to test_char_count()
int main() {
...
test_char_count(char_count);
...
// test_encoding_map(encoding);
...
// print_huffman_encoding(f_name, encoding);
}
Then, from inside the /test
directory, run
./test_char_count.sh
From inside the /test
directory, run
./test_decode.sh