CS 460, Spring, 2010

Lab 6 (two weeks)

 

Introduction

The purpose of this lab is to investigate applications of dynamic programming. You will do three problems, with some choice as indicated below.

 

Some of the problems ask you to show a version of a greedy algorithm does not work before developing a dynamic programming algorithm. In addition to developing an algorithm for each problem, you will need to prove that the algorithm solves the problem -- this usually follows easily from the construction of the algorithm, but do indicate how -- and give a complexity analysis in terms of the problem size.

 

For some of the problems, I have suggested variations. I do not know whther these variations can still be solved, but you should think about them. Perhaps you can come up with your own variation for a problem.

Algorithm

Your description of the algorithm must be completely precise and should include a description of the data representation used, so that operations accessing the data can be included in the analysis. For most dynamic programs the solutions to partial problems are stored in an array, dimension depending on the algorithm. A precise English description, precise pseudo-code, or a complete program in a language of your choice is acceptable.

Test Cases

You should provide test cases to demonstrate how your algorithms work. The test case for each algorithm should be small, but without making the application of the algorithm trivial. You should show how the step-by-step application of your algorithm works. You might want to do two such test cases to show differing outcomes of the algorithm when appropriate.

 

Problems

The problems for this lab are taken from the exercises for chapter 6 in K&T.

 

A. Exercise 2 -- give an example of the application of your algorithm with at least 8 time periods

OR

Exercise 3 -- give an example of the application of your algorithm with at least eight nodes in the digraph. (Note, the digraph is a DAG and the "ordered graph" is a topological ordering for the DAG.) What if each edge had a weight? Could your algorithm be extended to find the path with maximum sum of edge weights?

 

 

B. Exercise 17 -- give an example with at least ten days.

 

 

C. Exercise 24 -- give an example with at least 9 precincts.

Could you extend your algorithm to work for a situation where n precincts were to be divided into three districts so that one party could have a majority in all three districts if possible, or in two districts this is possible and three is not.

OR

Exercise 26 -- give an example with 12 months.

Could you extend your algorithm to cover a version of this problem where the ordering cost is K (the order cost) plus S for every five trucks (S represents the cost of a hauler which can hold up to 5 trucks). For example, an order for 1 to 5 trucks costs K + S, an order for 6 to 10 trucks costs K + 2S, and order for 11 to 15 trucks costs K + 3S, etc.?