Solutions to Practice Final
1.
Huffman code
Give a Huffman encoding into an alphabet of size
D
= 4 of the following
probability mass function:
p
= (
8
36
,
7
36
,
6
36
,
5
36
,
4
36
,
3
36
,
2
36
,
1
36
)
Solution: Huffman code
(1)
8
8
15
36
(2)
7
7
8
(3)
6
6
7
(00)
5
5
6
(01)
4
4
(02)
3
3
(030)
2
3
(031)
1
(dummy)
0
(dummy)
0
2.
Ternary Huffman word lengths
Which of the following sequences of word lengths
cannot
be the word
lengths of a 3-ary Huffman code and which
can
?
(a)
L
= (1
,
1
,
2
,
2
,
3
,
3
,
3)
(b)
L
= (1
,
1
,
2
,
2
,
3
,
3)
(c)
L
= (1
,
1
,
2
,
2
,
3)
(d)
L
= (1
,
2
,
2
,
2
,
2
,
2
,
2)
(e)
L
= (1
,
2
,
2
,
2
,
2)
Solution: Ternary Huffman word lengths
The simplest way is to draw a ternary tree for each case. Once we have
1