More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. W.A. Wulf
Huffman coding is a lossless data compression algorithm and derives this table based on the estimated frequency of occurrence for each possible value of the source symbol.
The most frequent character gets smallest code and least frequent character get the largest code. Two trees with the least frequencies are joined as the subtrees of a new root that is assigned the sum of their frequencies. Repeat until all characters are in one tree. One code bit represents each level. Thus more frequent characters are near the root and are coded with few bits, and rare characters are far from the root and are coded with many bits.
Write program to implement Huffman coding?
Huffman code for 'Hello World' char Weight HuffmanCode 1 000 r 1 001 e 1 010 W 1 011 l 3 10 o 2 110 H 1 1110 d 1 1111