LZW Compressor
2024 · C++ · Python · Streamlit

Overview
A web demo of the LZW compressor I wrote in C++ for the Algorithms 2 course at UFMG. You upload a file of up to 50 MB, pick the code size and get the compressed file, the compression rate, the time taken and confirmation that decompression gave back the original.
What I built
- LZW with a compact trie: the dictionary lives in a compact prefix tree, used for both compression and decompression.
- Two code modes: fixed at 12 bits, or variable from 9 to 12 bits, with the width growing along with the dictionary.
- Binary mode: the program reads and writes byte by byte, so it takes any kind of file, not only text.
- Streamlit app: Python compiles the C++ with g++, runs the executable in a temporary folder on each run and compares the result with the uploaded file.
A real result
On a 3.2 MB test text file, variable mode cut the size by 66.8% and fixed mode by 66.7%, both in under a second. Files that are already compressed, such as PNG, JPG or ZIP, have few repeated sequences and can even grow. The app says so when it happens.

