contents
coding
FLCvsVLC
UDC
Huffman-code
Codingtree
MATLAB-code
Input-output
conclusion
GENERATION OF HUFFFMAN
CODE AND DETERMIINATION
OF EFFICIENCY USING
MATLAB
By:-
ALAPAN RANJAN BANERJEE (03)
contents
coding
FLCvsVLC
UDC
Huffman-code
Codingtree
MATLAB-code
Input-output
conclusion
Source Coding
VLC vs FLC
Uniquly decodable
code
Huffman-Coding
Coding tree
Matlab-code
Input-output
Conclutions
contents
coding
FLCvsVLC
UDC
Huffman-code
Codingtree
MATLAB-code
Input-output
conclusion
SOURCE CODING
Eliminate redundancy
of data, send same
information using fewer
bits
Data is compressed
Bandwidth is efficiently
used
contents
coding
FLCvsVLC
UDC
Huffman-code
Codingtree
MATLAB-code
Input-output
conclusion
A->000 E->100
B->001 F->101
C->010 G->110
D->011 H->111
A->0 E->10
B->1 F->11
C->00 G->000
D->01 H->111
A->00 E->101
B->010 F->110
C->011 G->1110
D->100 H->1111
FLC VLC-1
VLC-2
“A BAD CAB”
FLC 000 001000011 010000001
VLC-1 00 01000100 01100010
VLC-2 :- 0 1001 0001
contents
coding
FLCvsVLC
UDC
Huffman-code
Codingtree
MATLAB-code
Input-output
conclusion
A->00 E->101
B->010 F->110
C->011 G->1110
D->100 H->1111
A->0 E->10
B->1 F->11
C->00 G->000
D->01 H->111
VLC-1 VLC-2
Uniquely Decodable Code
“A BAD CAB”
VLC-1 00 01000100 01100010 √
VLC-2 :- 0 1001 0001 X
contents
coding
FLCvsVLC
UDC
Huffman-code
Codingtree
MATLAB-code
Input-output
conclusion
Huffman Code is an example of VLC
Always start with the arrangement
of decreasing probability
Total sum should be 1
Take upward arrow as 0 and downward
as 1.
contents
coding
FLCvsVLC
UDC
Huffman-code
Codingtree
MATLAB-code
Input-output
conclusion
Let’s consider 7 symbols with there probability of
occurrence 0.4, 0.2, 0.12, 0.08, 0.08, 0.08, 0.04. construct
Huffman-codeword and calculate efficiency.
A=1
B=000
C=101
D=0010
G=0111
E=0011
F=0110
contents
coding
FLCvsVLC
UDC
Huffman-code
Codingtree
MATLAB-code
Input-output
conclusion •Define character string and
corresponding probability or
number of occurrence
•Iteratively sort and combine
symbols based on their
probabilities
•Create a min heap using the first 3
elements from probability array
and add the minimum elements.
•Repeat the step 2 and step 3 until
the array contains only 1 element.
•Make a record of added number
through a stack.
•Get all elements for the tree and
put weights on the tree
•A huffman codebook can be
calculated by traversing the
huffman tree while recording the
weights encountered while
travelling to each node.
contents
coding
FLCvsVLC
UDC
Huffman-code
Codingtree
MATLAB-code
Input-output
conclusion
INPUT:-
my_str = 'ABCDEFG'
prob_dist = [40 20 12 8 8 8 4]
OUTPUT:-
code word
'A -->0'
'B -->111'
'C -->100'
'D -->1011'
'E -->1101'
'F -->1100'
'G -->1010'
Efficiency of the code is
E =
97.6010
contents
coding
FLCvsVLC
UDC
Huffman-code
Codingtree
MATLAB-code
Input-output
conclusion
POs achieved:-
•Engineering Knowledge (PO1),
•Problem Analysis (PO2),
• Design & Development of
Solutions (PO3),
•Conduct Investigation of
Complex Problem (PO4),
•Modern Tool Usage (PO5),
• Individual and Team Work (PO9)
THANK
YOU

HUFFFMAN CODE