Huffman Coding Example

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Huffman Coding Example

Designing a Huffman Code for the entire alphabet is not difficult but tedious.
For illustration, we will only encode the following 7 letters:
Character Hexadecimal Number of ccurences !n" #ercentage !p"
e $% &&'( &(.%))*
h $+ ),%+ )&.&**%
l $C )($7 *.+($)
o $F )7,* )$.(7&*
p 7( %,7 %.('7)
t 7, ',7, ''.7&$*
w 77 '$$ '.,,,$
-otal: )(++) )((

Figure 2.14: Huffman coding.
-he resulting code is:
Character .inary Code
e ((
h ())
l ))(
o ()(
p )))(
t )(
w ))))
Some Conclusions
Example: -he binary se/uence
))))(()(())(()))(((()()))())(((
can be decoded as
wethepeople
-o encode all occurrences of the 7 characters we ha0e considered re/uires
Hence, we re/uire on a0erage '.%, bits per character.

You might also like