Huffman Coding

INTRODUCTION

This is a Huffman Compressor and Decompressor created by Xuan(James) Zhai. It is built with C++.

Its idea is to read a list of chars, in a txt file, as data and save each char as an 8 bits binary number. The program will build a Huffman tree based on those numbers. After the compression, the program will create a compressed.txt and save the compressed code. It will also create a key.txt to store the tree.

The decompression will rebuild the tree based on the key.txt and find the decompressed code with compressed.txt. After that, it will store the decompressed data into Decompressed.txt, and it will compare that with the one before compression.

How to Run the Code

You will need to pass in a parameter which is the filename of your file that you want to compress.

It will create compressed data and decompressed data as txt files.

It will also print the comparison accuracy to the prompt.

WHERE TO DOWNLOAD

ABOUT THIS PROJECT

1: When it compresses a file, it will generate a compressed file and a key.

2: The compression ratio will be around 75%-90% (combing the compressed file and the key) depending out the size of the input file. A larger file or a file with many common words may show a lower ratio.