Q&A II – Sunday Feb 13 th 2011 BITS
Signed binary What are the following numbers in signed binary?
Huffman Tree Rules Steps for generating a Huffman code tree: 1. Collect the symbols into a list and sort by frequency 2. Start with the two symbols that have the lowest frequency. These are going to be the top most leaves of the tree. Put the one with the lowest frequency on the LHS. Make a node combining the two symbols. This node now has a combined frequency of the two symbols above it. 3. Now insert your combined node back into the list and sort by frequency 4. Repeat until you have used up all the symbols. 5. Start labeling with 0’s and 1’s – 0’s on the left, 1’s on the right. 6. You can now read off the encoding for each symbol!
Huffman Tree Example I In 2005, auto manufacturers had market share in the United States according to the following table: Create a Huffman code that is optimal for this distribution ManufacturerMarket Share GM26.2% Ford18.6% Chrysler14.9% Toyota13.3% Honda8.6% Nissan6.3% Hyundai2.7% Other9.4%
5 ManufacturerMarket Share GM26.2% Ford18.6% Chrysler14.9% Toyota13.3% Honda8.6% Nissan6.3% Hyundai2.7% Other9.4% ManufacturerMarket Share ManufacturerMarket Share ManufacturerMarket Share ManufacturerMarket Share ManufacturerMarket Share
6
Huffman Tree Example I Write down a bit string for the sequence: Ford, VW, Honda, Ford, Chrysler, Toyota, Chrysler, GM, GM, Hyundai, BMW, GM, Toyota, Nissan What is the entropy of this sequence. What about the efficiency of the Huffman Code?
Huffman Tree Example II Character# of occurances e3320 h1458 l1067 o1749 p547 t2474 w266 TOTAL10881 Build a huffman code for this distribution
Huffman Tree Example II Character# of occurancesProbability e h l o p t w TOTAL
10 CharacterProbability e h l o p t w TOTAL100 CharacterProbability CharacterProbability CharacterProbabilityCharacterProbability CharacterProbability
11