Download presentation
Presentation is loading. Please wait.
1
HUFFMAN TREES CSC 172 SPRING 2002 LECTURE 24
2
Prefix Codes Consider a binary trie representing a code 1 0 1 1 0 0 00 01 1011
3
A possible code Suppose we have to transmit messages made up of {A,B,C,D,R} How many bits per character do we need?
4
1 0 1 0 11 0 0 000001 010 011 1 0 1 1 0 0 100101 110111 A B C DR How many bits for “ABRACADABRA”
5
Prefix Code To prevent ambiguities in decoding, we require the encoding tree satisfies the prefix rule “No code is a prefix of another” A=“0”,j=“11”,v=“10” satisfies the prefix code
6
0 1 0 1 11 10 0 1 01 011010 00 C A R D How many bits for “ABRACADABRA” B A = 101 B = 11 C = 00 D = 10 R = 011 01011011010000101001011011010 29 bits
7
0 1 0 1 11 10 0 1 01 011010 00 A C D B How many bits for “ABRACADABRA” R A = 00 B = 10 C = 010 D = 011 R = 11 001011000100001100101100 24 bits
8
Huffman Encoding Trie ABRACADABRA ABRCD 52211
9
Huffman Encoding Trie ABRACADABRA ABRCD 52211 42611
10
Huffman Encoding Trie ABRACADABRA ABRCD 52211 42611 0 0 0 0 1 1 11 ABRACADABRA = 0 100 101 0 110 0 111 0 100 101 0 (23 bits)
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.