# ps8 - Introduction to Algorithms Massachusetts Institute of...

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

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

View Full Document
2 Handout27:ProblemSet8 Exercise 8-4. Do exercise 23.1-8 on page 567 of CLRS. Exercise 8-5. Do exercise 23.2-2 on page 573 of CLRS. Problem 8-1. Typesetting In this problem you will write a program (real code that runs!) to solve the following typesetting scenario. Because of the trouble you may encounter while programming, we advise you to START THIS PROBLEM AS SOON AS POSSIBLE. You have an input text consisting of a sequence of words of lengths , where the length of a word is the number of characters it contains. Your printer can only print with its built-in Courier 10-point ﬁxed-width font set that allows a maximum of characters per line. (Assume that for all .) When printing words and on the same line, one space character (blank) must be printed between the two words. In addition, any remaining space at the end of the line is padded with blanks. Thus, if words through are printed on a line, the number of extra space characters at the end of the line (after word ) is There are many ways to divide a paragraph into multiple lines. To produce nice-looking output, we want a division that ﬁlls each line as much as possible. A heuristic that has empirically shown itself to be effective is to charge a cost of the cube of the number of extra space characters at the end of each line. To avoid the unnecessary penalty for extra spaces on the last line, however, the
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 07/09/2009 for the course CSE 6.046J/18. taught by Professor Piotrindykandcharlese.leiserson during the Fall '04 term at MIT.

### Page1 / 6

ps8 - Introduction to Algorithms Massachusetts Institute of...

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

View Full Document
Ask a homework question - tutors are online