14 Compression Part 2

14 Compression Part 2 - Compression, part 2 15-211:...

Info iconThis preview shows pages 1–22. Sign up to view the full content.

View Full Document Right Arrow Icon
Compression, part 2 15-211: Fundamental Data Structures and Algorithms Charlie Garrod 04 March 2010 Reading for today:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Announcements
Background image of page 2
3 Announcements
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Announcements HW4 is available Theory due in lecture Thursday, 18 March Programming due 11:59 pm, Monday, 22 March
Background image of page 4
5 Last time: Prefix-free codes “aaaebcbacfcaaaababaabbcciabbbbaaddcaccabcahdbaacabccbbaaba…” 10 11 01 0010 0000 0001 00110 001111 001110 h i g d f e c a b 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Last time: Huffman’s algorithm “aaaebcbacfcaaaababaabbcciabbbbaaddcaccabcahdbaacabccbbaaba…” 1) Count frequencies for each letter in message 2) Use frequencies to build Huffman code dictionary 3) Use Huffman code to encode message 4) Write the dictionary and the encoded message
Background image of page 6
7 Last time: Huffman’s algorithm “abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd…” (70 times)
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Last time: Huffman’s algorithm “abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd…” (70 times) b c d 0 0 0 1 1 1 a 00 01 10 11 Length:
Background image of page 8
9 Last time: Huffman’s algorithm “abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd…” (70 times) b c d 0 0 0 1 1 1 a 00 01 10 11 Length: Send the dictionary, plus 560 bits for the message
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10 Last time: Huffman’s algorithm “aaaaaaa…aabbbbbbb…bbcccccccc…ccddddddd….dd” b c d 0 0 0 1 1 1 a 00 01 10 11 70 70 70 70 Length: Send the dictionary, plus 560 bits for the message
Background image of page 10
11 Last time: Huffman’s algorithm “1111111111111111110111111111111111111111001111111111101111…” 1 0 1 0
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
12 Today: Compression, part 2 N-gram compression Adaptive compression algorithms Move-to-front LZW Java bytes
Background image of page 12
13 N-gram compression “aaaaaaa…aabbbbbbb…bbcccccccc…ccddddddd….dd” 70 70 70 70 1) Break message into chunks of size N 2) Apply Huffman’s algorithm to the chunks e.g., 4-gram compression:
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
14 N-gram compression “aaaaaaa…aabbbbbbb…bbcccccccc…ccddddddd….dd” 70 70 70 70 e.g., 4-gram compression: bbbb cccc dddd aaaa aabb ccdd 0 0 0 0 0 1 1 1 1 1 110 1110 00 01 1111 10 Length: Send the dictionary, plus 161 bits for the message
Background image of page 14
15 N-gram compression “abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd…” (70 times) e.g., 6-gram compression:
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
16 N-gram compression “abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd…” (70 times) e.g., 6-gram compression: cdabcd 0 0 1 abcd abcdab Length: Send the dictionary, plus 71 bits for the message 1
Background image of page 16
17 N-gram compression Problems?
Background image of page 17

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
18 N-gram compression Problems? N = ? “2-pass” compression algorithm
Background image of page 18
19 Adaptive compression Reduce code-length for recent or frequent letters/patterns e.g., abbbaaaaaddddddddaaaacccbbbbbcccccc… Add new patterns to the dictionary e.g., abcdabcdabcdabcdabcdabcdabcdabcd… Encoding: input message intermediate encoding output adaptive trans- formation bit encoding “abbaaa…” 1 3 0 1 5 … 00100111101…
Background image of page 19

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
20 Move-to-front (MTF) When we see a letter: Emit current list position Then move letter to front of list e.g., abbbaaaaaddddddddaaaacccbbbbbcccccc… b a c d e f
Background image of page 20