E0113chars z000011000 howtomakeshortestcodesfor

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: ariable length code Prefix Codes Prefix Codes Build a “decision tree”, characters at leaves EXAMPLES: Use to encode example: U = 10010 Use to decode example: 0101 = S Prefix Codes Prefix Codes IDEA: frequent letters should have SHORTEST codes, so overall space used is minimized. E = 011 (3 chars) Z = 000011000 How to make shortest codes for How to make shortest codes for most frequent letters David Huffman discovered the method: a term paper while a graduate student at MIT. ANIMATION: http://www.beluga.ch/code/apple Example Example AEDAECDEAEEBDCEEDBCDEEDAEBEB CCE Compute the frequencies of each letter: – A: 4 – B: 4 – C: 5 – D: 6 – E: 12 Example Example Letter Frequency A 4 B 4 C 5 D We build the tree from the bottom up. 6 E 12 Start with singleton vertices, labeled with their frequencies A B C D E 4 4 5 6 12 Find the two smallest frequencies, and combine t...
View Full Document

Ask a homework question - tutors are online