Implementation of Compression Huffman Algorithm in C++
Huffman's algorithm uses a file compression method based on the probability of occurrence of characters in text.
In this implementation the Huffman Algorithm is defined by the concept of digital search, described by Digital Search Tree, which will allow the compression and decompression of text files (.txt
).
This code will receive a input file, a .txt
file which will be compressed, and generates two files as output:
encoded.txt
: represents the compressed file, in binary. This file is the result of running Huffman's algorithm on the input file.decoded.txt
: represents the decoded file. This file is the result of applying Huffman's algorithm on theencoded.txt
file. In other words, it's decompression. This file works as a validation, because if the algorithm performed the compression/decompression process correctly, this file must be exactly equal to the file used as input for compression.
To run code just compile the files contained in src
folder. To do this, perform the following simple steps
-
Clone repository
git clone [email protected]:ViniciusMarchi/huffman-algorithm.git
-
Go to project folder
cd huffman-algorithm
-
Compile the file contained in
src
directory usingg++
with the following command:g++ -o compilled src/*.cpp
After compiling, just run the compiled file, passing as a parameter the .txt
input file to be compressed, for example.
./compilled input.txt