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.
The optimal BST problem is to build a binary search tree that is optimal not in terms of balance (which minimizes the worst case search time) but so as to minimize the expected case search time when the probability that a given key will be searched for is known ahead of time. In particular, keys that are more likely to be searched for are closer to the root than rarer keys.
The optimal BST can be built from a table of subtrees populated using dynamic programming.
This project can be found in the book as Project 6.2 on pg 506.
Find the project code in ~tvandrun/Public/cs345/optbst
.
As usual, it will have the three packages, adt
,
impl
, and test
,
and one additional package, optbstutil
,
which contains a class with a handful of useful static methods.
Implement the method
impl.OptimalBSTMapFactory.buildOptimalBST()
as described in Project 6.2
Your return statement will be something like
return new OptimalBSTMap( [root of the optimal tree] );
The package test
contains only one test file.
It tests for correctness and optimality of trees generated
by your factory method.
Copy the file you modified (OptimalBSTMapFactory.java
)
to your turn-in folder
/cslab/class/cs345/(your id)/optbst
.
To keep up with the course, this should be finished by April 17.