Thursday, 22 August 2013

How to write an output file in order to recunstruct Hoffman tree?

How to write an output file in order to recunstruct Hoffman tree?

I am writing a Hoffman compress program in which I am trying to write
instructions to the output file in order to reconstruct a Huffman coding
tree which will be used by the uncompress program to decode the message.
For example if I have a string ABC to compress what I am trying to figure
out how to do is how to store codes for each letter as a sort of code-book
that will be used to uncompress the message. So far I have constructed a
vector that will count number of occurrences for each char in the ASCII
table but I can't figure out how to write this info in the output file so
this info is used to rebuild the tree and decode the message. This is what
I have so far:
vector<int> v (256,0)
// code to fill in the vector with occurences of each of the letters
//in the ASCII tablewhich I have no problem with
outfile.open(outputFile, ios::binary);
// code to write info to output file
What do I do here?

No comments:

Post a Comment