| | |
huffman code
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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!
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!
Google is your programming friend! Here's what I found with "Huffman algorithm":
http://ciips.ee.uwa.edu.au/~morris/Y...0/huff-op.html
Looks like just what you want!
http://ciips.ee.uwa.edu.au/~morris/Y...0/huff-op.html
Looks like just what you want!
•
•
Join Date: Aug 2004
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by apurva agarwal
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
* http://alexvn.freeservers.com/s1/huf...algorithm.html
* http://sourceforge.net/projects/huffman-ta/
•
•
•
•
Originally Posted by nbrmkumaresh
Please give me an idea of how to do program the huffman code in C
http://www.daniweb.com/code/snippet5.html
Test it, improve it, learn from it!
May 'the Google' be with you!
Stop begging for code. Do your own work and read this thread http://www.daniweb.com/forums/announcement8-2.html
There are 10 types of people in the world, those who understand binary and those who don't.
All generalizations are wrong. Even this one.
All generalizations are wrong. Even this one.
![]() |
Similar Threads
- huffman code (C)
- huffman code (C++)
Other Threads in the C++ Forum
- Previous Thread: Warning on Overloaded stream operators
- Next Thread: files(plz help)
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






