Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves. Alan Kay

Huffman coding

Language Java | Level Intermediate | Category Algorithms | August 4, 2015 9:44 am

Algorithm Problem Description

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



Please login to add comments.