08 - Greedy Algorithms (Solution)

08 - Greedy Algorithms (Solution) - The Hong Kong...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
COMP 271: Design and Analysis of Algorithms Fall 2007 Tutorial 8: Greedy Algorithms Below is the suggest solution to the tutorial questions. Question 1 : A fle contains only colons, spaces, newlines, commas, and digits in the Following Frequency: colon (100), space (605), newline (100), comma (705), 0 (431), 1 (242), 2 (176), 3 (59), 4 (185), 5 (250), 6 (174), 7 (199), 8 (205), 9 (217). Construct the Hu±man code. Solution: 3 / 59 colon/ 100 n 1 / 159 newline/ 100 6 / 174 2 / 176 n 2 / 259 n 3 / 350 1 / 242 5 / 250 4 / 185 7 / 199 8 / 205 9 / 217 n 7 / 609 space/ 605 n 6 / 492 0 / 431 n 4 / 384 n 5 / 422 n 10 / 1214 n 9 / 923 n 8 / 806 comma/ 705 n 12 / 2137 n 11 / 1511 n 13 / 3648 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
The Hufman code is: character code colon 000001 space 001 newline 00001 comma 11 0 011 1 0100 2 00011 3 000000 4 1000 5 0101 6 00010 7 1001 8 1010 9 1011 2
Background image of page 2
Question 2 : Show that none of the following greedy algorithms for the chain matrix
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/18/2009 for the course COMP 271 taught by Professor Arya during the Spring '07 term at HKUST.

Page1 / 3

08 - Greedy Algorithms (Solution) - The Hong Kong...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online