Huffman Tree Compressor
This was a university project on algorithms and data structure. The idea is to develop a cpp program that can successfully compress and decompress a file without loss of information. My intention in presenting this project is to demonstrate my abilities in algorithmics.
Implemented technologies
- C++
Process and challenges
Library to read/write bits: for this I had to unset each character using the operators whose utility is to move. To write bits, I made an array where 1s and 0s were written, and when it reached the number of 8 converted it to ASCII using the typical decimal-to-binary algorithm (sum of 2 raised to that n position).
File walking: during the course we developed a library that read/write files using native c++ fread and fwrite (stdio.h)..
Save the bits in an array with their number of occurrences, then sort by number.
Create tree.
Write header so we can rebuild the tree.
As the file is read again, we must generate each key of each character with the tree and write it to another file..
To unzip: rebuild tree reading header.
Reading the content, figure out what character it is by looking in the huffman tree.
Write decrypted file.
Conclusion and next steps
I would like in the future to deploy this project to a lambda function and make a small site to make use of this algorithm.