Professional Documents
Culture Documents
2 1 4
B A C
Step2-Sort the characters in increasing order of the frequency
1 2 4
A B C
Message- BBACCCC
7
0 1 Character probabil Frequen
Code Size
ity cy
3 4 A 0.143 1 00 1*2 = 2
0 1 C
B o.286 2 01 2*2 = 4
1 2 C 0.571 4 1 4*1 = 4
A B 3 * 8 = 24
bits
1 7 bits 10 bits
First of all place the counts in increasing order then
take minimum and add them now the root node of The encode Binary string for BBACCCC is 0101001111
letter A and B is 3.
Then between the root node 3 and counts take the Without encoding, the total size of the string was 48 bits.
minimum and add them up . Here 4 is minimum so we
add them and make 7 as root node. After encoding the size is reduced to 10bits
Mark the left hand edges as 0 and right hand As we see first we do need 48 bits and now we need 10 bits now we
edges as 1 and then traverse from root node to
any letter . have compressed the cost and size.
Advantages/Disadvantages
• Advantages : The Huffman Coding has the
minimum average length. Easy to implement and
fast.