I’m learning huffman algorigthm for text compression and decompression.
As per compression, I wrote this code and it works.
So,basically i have txt file with some encoded text.
Now, i want to decompess this file to restore source text and there is a moment when i’m struggling with it.
My question is, how compessed file(by huffman) should look like, that i can decompess it.
Please pay attention, that all i have is compessed file / no tree, no nodes, codes I do not store, only ascii representation of binary code
First off, to compress:
I built a tree by creating new nodes from the sum of the two smallest ones, got the binary values of each character, and translated them into the ascii represantation(8 bits = 1 ascii char)
For example:
Input file:
idonotknowhowtodecompessfilewithhuffman
Output file:
ТўсW╞ё░¤Ої&┴1║╩дm
I realise that I need to recreate the tree, convert the ASCII representation to binary and use the tree to recreate the original text later.
However, I do not understand how the compressed file should look like.
Олег Терно is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.