Encoding and Decoding
Encoding: send the code, then the encoded data
x = aabddcaa
c(x) = a0,b100,c101,d11,0010011111010 0
Decoding: Build the Huffman tree, then use it to decode.
Huffman code
code of x
repeat
start at root of tree
repeat
if node is not a leaf
if read bit = 1 then go right
else go left
report leaf
b
c
a
d
0
0
0
1
1
1
Previous slide
Next slide
Back to first slide
View graphic version