ps5sol - Introduction to Algorithms Massachusetts Institute...

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

View Full Document Right Arrow Icon
Introduction to Algorithms Octoberber 31, 2004 Massachusetts Institute of Technology 6.046J/18.410J Professors Piotr Indyk and Charles E. Leiserson Handout 21 Problem Set 5 Solutions Reading: Chapters 15, 16 Both exercises and problems should be solved, but only the problems should be turned in. Exercises are intended to help you master the course material. Even though you should not turn in the exercise solutions, you are responsible for material covered in the exercises. Mark the top of each sheet with your name, the course number, the problem number, your recitation section, the date and the names of any students with whom you collaborated. Three-hole punch your paper on submissions. You will often be called upon to “give an algorithm” to solve a certain problem. Your write-up should take the form of a short essay. A topic paragraph should summarize the problem you are solving and what your results are. The body of the essay should provide the following: 1. A description of the algorithm in English and, if helpful, pseudo-code. 2. At least one worked example or diagram to show more precisely how your algorithm works. 3. A proof (or indication) of the correctness of the algorithm. 4. An analysis of the running time of the algorithm. Remember, your goal is to communicate. Full credit will be given only to correct algorithms which are which are described clearly . Convoluted and obtuse descriptions will receive low marks. Exercise 4-1. Do Exercise 15.2-1 on page 338 in CLRS. Exercise 4-2. Do exercise 15.3-4 on page 350 in CLRS. Exercise 4-3. Do exercise 15.4-4 on page 356 in CLRS and show how to reconstruct the actual longest common subsequence. Exercise 4-4. Do exercise 16.1-3 on page 379 in CLRS. Exercise 4-5. Do exercise 16.3-2 on page 392 in CLRS. Problem 4-1. Typesetting In this problem you will write a program (real code that runs!!!) to solve the following typesetting problem. Because of the trouble you may encounter while programming, we advise you to START THIS PROBLEM AS SOON AS POSSIBLE.
Background image of page 1

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

View Full DocumentRight Arrow Icon
± ² 2 Handout 21: Problem Set 5 Solutions You have an input text consisting of a sequence of n words of lengths 1 , 2 , . . . , n , 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 fixed-width font set that allows a maximum of M characters per line. (Assume that i M for all i = 1 , . . . , n .) When printing words i and i + 1 on the same line, one space character (blank) must be printed between the two words. Thus, if words i through j are printed on a line, the number of extra space characters at the end of the line—that is, after word j —is M j + i j k .
Background image of page 2
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 01/20/2012 for the course CS 6.006 taught by Professor Erikdemaine during the Fall '08 term at MIT.

Page1 / 12

ps5sol - Introduction to Algorithms Massachusetts Institute...

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