Project 4: Dynamic programming; optimal BSTs

The goal of this project is to practice using dynamic programming to implement a solution to an optimization problem. In particular you will write an method for building and optimal BST.

1. Set up

Find the project code in ~tvandrun/Public/cs345/proj4. As usual, it will have three packages, adt, impl, and test. Remember that using the cp command as

cp -r ~tvandrun/Public/cs345/proj4/. .

will grab the hidden .classpath file so that Eclipse wlll but the JUnit libraries in the build path when you start an Eclipse project.

Speaking of which, make a new Eclipse project. Remember to make the project in the folder containing the adt etc folders.

The adt package has the same Map interface as in the previous project (no remove() method). The put() method is still there, but the OptBSTMap class doesn't support it.

2. Your task

Implement the method impl.OptimalBSTMapFactory.buildOptimalBST(). It is possible that you will find if useful to carve some of the functionality into helper methods (though my solution had the whole algorithm in one method).

The package test contains only one test, which uses buildOptimalBST() to build the tree in the example from class. I intend to give you a few more before the project is over. I recommend you write your own tests as well.

3. Turn-in

cp OptimalBSTMapFactory /cslab.all/ubuntu/cs345/turnin/(your id)/proj4

Due Wednesdayday, March 18, 5:00 pm.


Thomas VanDrunen
Last modified: Thu Feb 12 11:34:38 CST 2015