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.

Please give me an idea of how to do program the huffman code in C

Please give me an idea of how to do program the huffman code in C

Check the C code snippet right here on DaniWeb:
http://www.daniweb.com/code/snippet5.html

Test it, improve it, learn from it!

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

I did not see the date either :)

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++

commented: Fail. -4
commented: Did you read the rest of the thread??? -1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.