hi!!
i want to know about the huffman algoriyhm and its implementation.
how the huffman code works and its use, a code in c/c++ language

Huffman was a guy who realized that letters do not occur statisticly randomly; 'e' is used a lot more than 'j'. He figured you could build a balanced tree of letters (or anything else that occurs non-randomly, like words) and using that tree, represent letters in a minimal number of bits.

The original Huffman went like this:
1) count the occurances of the letters in your text to be compressed
2) build a binary tree such that the shortest paths in the tree go to the most referred-to letters
3) encode the tree as bits, where a 0 means go LEFT on the tree and 1 means go RIGHT.

Later variants allowed the tree to be built dynamically as you see the charactors, as in processing a stream of bytes.

Huffman is used as the post-processing in many compressors, like gzip (which first removes blocks of common letters and then Huffmanizes the result) and jpeg (which converts pixels into cosine values and Huffmanizes the resulting (nearly the same) values).

Google will get you to some sample code easily. Now that you know the basics, the code should be pretty readable.

Good luck!

thanks a lot !!!!
but i have a problem with the code i have counted the frequency but i am not able to build the heap which i have to build to finally make a tree.
help me here!!!!

hi!!
i want to know about the huffman algoriyhm and its implementation.
how the huffman code works and its use, a code in c/c++ language

I would be highly grateful if u give me the code

>I would be highly grateful if u give me the code
I'm sure you would. Do your own work, it's much more rewarding.

Sorry Salem, but I deleted a new instance of begging from this morning. hammerhead's post is legit.

hi!!
i want to know about the huffman algoriyhm and its implementation.
how the huffman code works and its use, a code in c/c++ language

How do we construct the Hoffman's code in C++

Comments
Did you read the rest of the thread???
Fail.
This article has been dead for over six months. Start a new discussion instead.