Discrete Math Notes:
Chapter 6: Graphs and Trees
6.8 Tree application examples
variable length codes, the number of bits for each character can vary
prefix,
prefix code, has the property that the code for one character cannot be a prefix of the code for another character
overview:
Example of trees and variable length decoding
Decode: 11101010110
Output word.
Captions ^
1.Decode 11101010110.The first bit is 1, which says go right.Follow the edge to the right child of the root. 2. The next bits are 11 0. Travel right, right, and then left down the tree. A leaf is reached with Iabel s. Outout s and go back to the root. 3. The next bits are 101. Travel right, left, and then right down the tree. A leaf is reached with Iabel t. Ouiput t and go back to the root. 4. The next bi1 is 0. Travel right down the tree. A leat is reached with label a. Output a and go back to theroot 5 The next bits are 110. Travel right, right, and then left down the tree. A leaf is reached with Tabel r. Output r. The end of the sequence is reached. The output word is star
Fixed length encodings include ASCII and Unicode. Variable length codes, in which the number of bits for each character can change, can produce more space-efficient encodings. If all of the characters in string s occur at the start of string t, it is a prefix of another string t. The property of prefix code is that one character's code cannot be a prefix of another character's code.