Assignments | Course Home | Schedule & Lecture Notes

Saint Louis University

Computer Science 314
Algorithms

Michael Goldwasser

Spring 2007

Dept. of Math & Computer Science

Homework Assignment 06

Dynamic Programming

Contents:


Overview

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.


Practice Problems


Problems to be Submitted (40 points)

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:

  1. Describe the space of subproblems (most notably, the parameterization you use).
  2. How many subproblems are there in total?
  3. Give a clear and concise recursive formula which is used to compute the values of the subproblems (including any relevant base cases).
  4. How long does it take to compute the value of a single subproblem using the recursive formula?
  5. What is the asymptotic running time of your complete program?

  1. (20 points)

    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 L
    
    It 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.

  2. (20 points)

    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).


Michael Goldwasser
CSCI 314, Spring 2007
Last modified: Tuesday, 10 April 2007
Assignments | Course Home | Schedule & Lecture Notes