You are on page 1of 7

Topic : Huffman Coding Method

Power System Communication Course


MYO ZAW OO(3122999029)
Definition
 Huffman Coding is a lossless data compression
algorithm. The idea is to assign variable-length
codes to input characters, lengths of the assigned
codes are based on the frequencies of
corresponding characters.

 The most frequent character gets the smallest


code and the least frequent character gets the
largest code.
Message- BBACCCC
Length-6
In Electric components the alphabet is sent through
ASCII code . The ASCII code letter capital A is 65 and
we need 8 bits binary to convert 65.

For 1 Letter We need 8 bits Add your title


Add your words here,according
to your need to draw the text

For 6 Letters We need 8*6=48 bits


box size
Message- BBACCCC
Step1-Calculate the frequency of each character in the string

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.

• Disadvantages : Requires two passes over the two input


(one to compute frequencies, one for coding),thus
encoding is slow. Requires storing the Huffman codes(or
at least character frequencies)in the encoded file, thus
reducing the compression benefit obtained by encoding.
Simulation(C#programing language)

You might also like