oClass-5-10-10

# oClass-5-10-10 - BINARY TREES next next Leaf letter codes...

This preview shows pages 1–8. Sign up to view the full content.

BINARY TREES next

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

View Full Document
next
Leaf letter codes Using these codes a Fle with letter frequencies N N N N N N N A B C D E G ± Could be stored using a total of bits Can we do better by using another tree? What is the best tree? next

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

View Full Document
Leaf heights of binary trees Incomplete tree Complete tree Proof By induction on the height of the tree Assume the result true for all trees of height less than k a) Every binary tree of length k decomposes into one or two trees of length less than k b) all the heights increase by one --> all denominators increase by a factor of 2 next QED!! 1/2 1/2
The Huffman Code The goal is to use a code that gives shorter codes to the more frequent letters in order to minimize the number of bits used in to store the Fle The following algorithm gives the optimal tree Each step is the same: join the two partial trees with minimum total weight Notice that we rearrange the sequence of nodes so that the weights increase from left to right total weight next

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

View Full Document
Continuing the construction next
Final Tree 0 0 0 0 0 0 1 1 1 1 1 1 Note using the formula We get (Pretty good!) 2.62165 next

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 09/22/2010 for the course MATH MATH187 taught by Professor Math187 during the Spring '10 term at UCSD.

### Page1 / 13

oClass-5-10-10 - BINARY TREES next next Leaf letter codes...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online