Lossless Compression Page 294 298 Lauren DArcangelo Overview

  • Slides: 7
Download presentation
Lossless Compression Page 294 -298 Lauren D’Arcangelo

Lossless Compression Page 294 -298 Lauren D’Arcangelo

Overview • Dictionary encoding: create a • • dictionary (a table) of strings used

Overview • Dictionary encoding: create a • • dictionary (a table) of strings used during the communication session. Steps to compression Steps to decompression

Compression… • Decompressed String: • • BAABABBBAABBBBAA Step 1: Extract smallest substring from original

Compression… • Decompressed String: • • BAABABBBAABBBBAA Step 1: Extract smallest substring from original string (B). B is index 1. B is inserted in the compressed string. Remaining String: AABABBBAABBBBAA Step 2: Extract next smallest substring from the remaining string (A). A is index 2. A is inserted in the compressed string. Remaining String: ABABBBAABBBBAA Index 1 2 Character B A Compressed String B, A

Compression… • Remaining String: • • ABABBBAABBBBAA Step 3: Extract the next smallest substring

Compression… • Remaining String: • • ABABBBAABBBBAA Step 3: Extract the next smallest substring from the original string, that isn’t in the dictionary (AB). AB is index 3 Find the substring without the last character (A). The index for A is 2, replace A with 2 and insert 2 B in the compressed string. Index 1 2 3 Character B A AB Compressed B, A, 2 B String

Compression… • Remaining String: ABBBAABBBBAA • Step 4: Extract ABB, because A • •

Compression… • Remaining String: ABBBAABBBBAA • Step 4: Extract ABB, because A • • and AB are already in the dictionary. ABB is index 4. Find the index of the substring without the last character (AB) which is 3. 3 B is inserted into the compressed string. When the steps are completed the final compressed string is: B, A, 2 B, 3 B, 1 A, 4 B, 5 A Index 1 2 3 Character B A AB ABB Compressed B, A, 2 B, 3 B String 4

Decompression • Compressed String: B, A, 2 B, 3 B, 1 A, 4 B,

Decompression • Compressed String: B, A, 2 B, 3 B, 1 A, 4 B, 5 A • Step 1: Find first substring of the Index 1 2 • • 3 4 compressed string (B). B has no index; Character B A AB ABB B is inserted to decomposed string. Step 2: Find the second substring (A). Insert A into the decompressed string. Step 3: Find the third substring (2 B). Search the dictionary and replace the index 2 with the substring A. AB is added to the decomposed string. Step 4: Find the fourth substring (3 B). Search the dictionary and replace the index 3 with the substring AB. The substring ABB is added to decompressed string. The final decompressed string is: BAABABBBAABBBBAA

THE END

THE END