This C program implements the huffman-coding algorithm for encoding and decoding text files by creating variable-length codes for characters in a text file based on the probability of occurrence of each character.
Compilation:
make -C ./srcThe user can run the program with four different argument inputs:
- Reads the data.txt file, calculates the probabilities of the first 128 characters of the ASCII table and prints them in the probfile.txt file.
./src/huffman -p ./data/data.txt ./data/probfile.txt- Reads the probabilities of each character form the probfile.txt file, creates the Huffman tree and prints the code for each character in codes.txt file and on the screen.
./src/huffman -s ./data/probfile.txt- Encodes the data.txt file using the Huffman tree and creates the encoded file data.txt.enc.
./src/huffman -e ./data/probfile.txt ./data/data.txt ./data/data.txt.enc- Decodes the data.txt.enc file using the Huffman tree and creates the decoded file data.txt.new.
./src/huffman -d ./data/probfile.txt ./data/data.txt.enc ./data/data.txt.new Giorgos Argyrides (g.aryrides@outlook.com)