
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















Thinh Nguyen Oregon State University
Creating a Code: The Data CompressionProblem ^ Assume a source with an alphabet
Merge the least probable symbols.
-^
Sort.
2.^
MergeSort Assign
0 1
0 10 11
0 10 110 111
Get code
1.^ Given any two letters a
and aj
, if P(ak
) >= P(aj
) , then lk
<= lj
,k
where l
is the length of the codeword aj^
.j
2.^ The two least probable letters have codewords with the samemaximum length l
m.
3.^ In the tree corresponding to the optimum code, there must betwo branches stemming from each intermediate node.4.^ Suppose we change an intermediate node into a leaf node bycombining all the leaves descending from it into a compositeword of a reduced alphabet.
Then if the original tree was
optimal for the original alphabet, the reduced tree is optimal forthe reduced alphabet.
Condition 1:
^ Suppose
a code X is optimal with P(a
) >= P(aj
), but lk
lj k
^ By simply exchanging a
and aj^
we have a new code Y in whichk,
its average length
^ Hence, the contradition is reached.
Thus, condition must hold
Condition 3:
.
^ If there were any intermediate node with only one branchcoming from that node, we could remove it without affecting thedecodability of the code while reducing its average length.
a^
b
c a: 000b: 001c: 1
a^
b
c a: 00b: 01c: 1
Suppose we change an intermediate node into a leaf node by combiningall the leaves descending from it into a composite word of a reducedalphabet.
Then if the orginal tree was optimal for the original alphabet, the reduced tree is optimal for the reduced alphabet.
a^
b
d 1 c a: 000b: 001c: 01d:
(^0) e
d 1 c
e: 00c: 01d:
Optimal Code Length (Huffman Code
Length)
1 )(
)(
< − ≤
S H l S H
source theof
Entropy:) ( log) ( )(
code optimalan of length Average:
1
2
i
m i
i^
aP
aP
l SH
∑= −
−=
n SH l SH
/ 1 )(
)(
< − ≤
source the of
Entropy:) (
Code
Huffman of length
− Average: l^ SH
} ... ,..., ... , ... { }, ,... {^
2 (^11)
n times
1 (^11)
(^2) , 1
m mm
n m^
a aa a aa a aa A a aa A^
43 (^421) =
=
alphabet A in the symbols
n
nm