CSE 143 Lecture 24 Priority Queues; Huffman Encoding slides created by Marty Stepp and Daniel Otero
Lecture 2: Huffman Codingdttin/Data compression/Lecture 02... · 2013-02-27 · 2/27/2013 15...
Transcript of Lecture 2: Huffman Codingdttin/Data compression/Lecture 02... · 2013-02-27 · 2/27/2013 15...
2/27/2013
1
Lecture 2
Huffman Coding
2/27/2013
2
2/27/2013
3
2/27/2013
4
2/27/2013
5
2/27/2013
6
2/27/2013
7
2/27/2013
8
2/27/2013
9
2/27/2013
10
2/27/2013
11
2/27/2013
12
2/27/2013
13
2/27/2013
14
Multiple code
Letter Probability Code
a1a1 0.64
a1a2 0.016
a1a3 0.144
a2a1 0.016
a2a2 0.0004
a2a3 0.0036
a3a1 0.1440
a3a2 0.0036
a3a3 0.0324
-------------
∑ P (aiaj) = 1
2/27/2013
15
Exercises
1. Using the Huffman tree constructed in this session, decode the
following sequence of bits, if possible. Otherwise, where does the
decoding fail?
10100010111010001000010011
2. Using the Huffman tree constructed in this session, write the bit
sequences that encode the messages:
test , state , telnet , notes
•
3. Mention one disadvantage of a lossless compression scheme and one
disadvantage of a lossy compression scheme.
4. Write a C/C++/Matlab program that implements the Huffman coding
algorithm.