Professional Documents
Culture Documents
Assignment 3
I 0 1 2 3 4 5
pi Null 0.12 0.06 0.10 0.12 0.16
qi 0.06 0.08 0.06 0.12 0.04 0.08
Solution:
Solution:
First we put the values of all elements in the table
f
a 14
b 41
c 17
d 33
e 8
f 7
g 22
h 11
15
7 8
Now remove these values from the table and add 15.
Step 2: take the next smallest values and add them in the tree nodes and remove from table:
25
11 14
47
22 25
11 14
32
Step 4:
15 17
7 8
Step 5:
65
32 33
Step 6: Step 7:
88 153 153
0 1
65
41 65 88
47 88
0 1 0 1
32 d:33 b:41 47
0 1 1
0 we shall make complete
As we have inserted all the elements of the table in the tree nodes, now
Huffman tree.
15 c:17 g:22 25
0
1 0 1
32
The Huffman codes for the frequencies are:
f Optimal
Huffman Codes
a 14 1111
b 41 10
c 17 001
d 33 01
e 8 0001
f 7 0000
g 22 110
h 11 1110