3/25/13 ¡ 1 ¡
CS200 Algorithms and Data Structures Colorado State University
PA3: Com
- mpres
essing Data using Hu Huffm ffman Cod
- ding
Sangmi Pallickara
CS200 Algorithms and Data Structures Colorado State University 3/25/13 Samgmi Lee Pallickara 2 CS200 Algorithms and Data Structures Colorado State University
Com
- mpres
essing Data using Hu Huffm ffman Cod
- ding
- Take String input
- Generate compressed bits
CS200 Algorithms and Data Structures Colorado State University
Hu Huffm ffman cod
- ding?
- Uses the symbols and their frequencies
- Constructs rooted binary tree
– Symbols are stored in the leaves
- Example:
- AEMMMEEKKMAABBBEEEEGGGMMMGGK
MGKKKKKMMMMAKKKKMEGGGKKKKKKBB EEEEMGGGMMMABBMMABBBMMMMGGGM MMMMMMKKKMMMAAMM
CS200 Algorithms and Data Structures Colorado State University
Crea eate e a Fr Freq equen ency table e
Character ¡ Frequency ¡ Huffman ¡code ¡
A ¡ 8 ¡ B ¡ 10 ¡ E ¡ 12 ¡ G ¡ 15 ¡ K ¡ 20 ¡ M ¡ 35 ¡
CS200 Algorithms and Data Structures Colorado State University
Start fr from
- m a For
Fores est of
- f Trees