This preview shows page 1. Sign up to view the full content.
Unformatted text preview: mutually compatible activities of Sk. This shows that it fulfills the greedy choice property
The optimal substructure property is shown in slide 30 On board --> 64 Huffman Codes 65 Compression Phase
Determine the frequencies of the characters stored
in the source file. 1. a) Read the source file b) Then store the character frequencies in a min-heap 2. Build a tree of prefix codes (a Huffman code) that
determines the unique bit codes for each character. 3. Write the prefix codes or code tree to the output
file. 4. Re-read the source file and for each character
read, write its prefix code into the output file. a)
66 You must WRITE the prefix code/tree and the encoded
file to the SAME output file Huffman coding example From Weiss, page 416 Uses 5 letters (a, e, i, s, t), plus the space and the newline
Total of 58 characters Normal ASCII encoding is 8 bits per character 58*8 = 464 bits
Which is 58 bytes, obviously Straight encoding is 3 bits per character 58*3 = 174 bits Which is 21.75 bytes 67 Compression step 1 (a) Determine frequencies of le...
View Full Document
This note was uploaded on 02/25/2014 for the course CS 4102 taught by Professor Horton during the Spring '10 term at UVA.
- Spring '10