A C implementation of file compression and decompression based on Huffman's compression algorithm.
The idea behind Huffman Coding is to minimize the weighted expected length of the code by assigning shorter codes to frequently used characters and longer codes to rarely used characters.
- Reads the file and counts the frequency of each character.
- Build the Priority Queue using Min Heap
- Build the Huffman tree
- Calculate the Huffman code for each character
- Read the file again, and encode it to a new file, and store the Huffman Table.
- Read the file and build a map containing the code of each character
- Decode the compressed file and write it to a new file.
If on Linux or have Make installed in Windows/macOS compile with:
make
Else compilation could be done by running the following commands:
gcc -c main.c
gcc -c encode.c
gcc -c decode.c
gcc -o app main.o encode.o decode.o
After compilation the app could be run with the command:
./app