Although you are required to complete certain specific tasks, you are also invited and encouraged to use this assignment as a starting point for your own investigations into applications of dynamic programming in text formatting.

Two strategies are popular---greedy and dynamic programming. The greedy approach, which is used for example by ClarisWorks (a popular wusiwyg text formatting program for the Mac), simply fills the current line word-by-word until the line is full. The more sophisticated dynamic programming approach, such as that used by TeX and LaTeX (document preparation systems for mathematical text), attempts to find a more beautiful formatting of the input paragraph by considering many possible line breaks. Your task is to compare these two approaches.

For simplicity, limit your work to fixed-width fonts (each character of the alphabet has the same width), and do not hyphenate any word.

For each algorithm, experimentally evaluate the algorithm in two ways: measure the actual running time, and numerically score the quality of results (as scored by an objective function). Be sure to test each algorithm on a variety of input sizes and for several input texts for each input size.

Although not required to do so, you are invited also to measure the actual space usage of each algorithm.

All implementations must be done in the C or C++ programming language.

- In terms of time, space, and quality of results, how do the greedy and dynamic programming approaches to text formatting compare?
- Concretely show many sample runs (including the input, output, running times and space usage). A large portion of your project grade will depend upon your choice of sample runs. Your suite of sample runs should be robust and should illustrate the performance of the algorithms in a variety of situations. In particular, they should include situations where each algorithm produces relatively good and relatively bad performances.
- How is the performance of the dynamic programming solution to Problem 16-2 affected by modifications to the objective function? For example, what happens if the cubic objective function is changed to a linear or quadratic function? Can you suggest and test other interesting objective functions? How well do these quantitative objective functions match with your subjective evaluations of the beauty of the results?
- Why does ClarisWorks use a greedy approach to text formatting?
- Another problem in text formatting is page breaking--deciding where each new page should begin. Discuss the advantages and disadvantages of computing page breaks with a dynamic programming strategy. Why do you think that TeX does not use a dynamic programming approach to page breaking?

Whenever possible, summarize your important experimental findings in appropriate graphs. As a separate appendix to your report, include a well-documented copy of all source code. For more about technical reports, see Alan Sherman's Guide to writing technical reports.

Last Modified: 2/19/97

Alan T. Sherman, sherman@cs.umbc.edu