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.
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...