Saint Louis University |
Computer Science 314
|
Dept. of Math & Computer Science |
Topic: Dynamic Programming
Related Reading: Ch. 6
Due:
Friday, 27 April 2007, 1:10pm
Please make sure you adhere to the policies on academic integrity.
See "Solved Exercises" in Chapter 6 of text
For this assignment, we are going to go with two implementation problems. For each you will be asked to submit a working implementation (language of your choice) as well as a brief writeup explaining the high-level structure of your dynamic programming problem. Namely, give an outline of:
Exercise 6 of Chapter 6 (p. 317-318) describes a model for balancing lines of text given a maximum line width L.
Write a program named balance which implements the approach suggested by this problem. Your program should take two command-line arguments, of the form:
balance filename LIt should break the original file into presumed "words" based on any form of separating whitespace, and then should rewrite that same text as output to the standard console, yet with the linebreaks determined to optimize the square of the slacks at the end of the lines.
As a plug for next year's ACM Programming Contest, we'll borrow a problem which appeared on a past Midwest Regional. (we'll give you the extra hint that dynamic programming should be used).
Your program should be able to handle input with the limits described in the problem in a "reasonable" amount of time (the equivalent of one minute or less on a standard PC).