Due: 9 November.
Write the code for the following problem. Turn your solution into the class server in the ps8 folder. You must follow all of the programming guidlines given in the Program Format Guide .
The iBST is used in two places. It is used in place of the linear list in the crossing distribution solution. If you look at the code on page 595 (Program 15.13), you'll notice that there are 4 data structures used in the program. The first declaration is for a variable named list that is of type ArrayLinearList. The type of list will change to be an indexed binary search tree. The remaining three variables will continue to be arrays. In this case, you should not have to change the code for the indexed binary search tree. You will have to change some of the method calls that list made since the methods used in the indexed binary search tree are different than the methods used in the ArrayLinearList class.
If you look at the crossing distribution solution provided by Sahni, you'll note that he hardcodes in the "C" array (the crossing distribution) and the "k" array (the crossing table). You will have to provide for input of the "C" array from a file and will have to create the "k" array.
This presents your second, and more interesting, challenge: creating the k array (the crossings table). You must also use an indexed binary search tree to create this array. The technique is described in some detail on page 597 of your text book and is covered in greater detail in the lecture slides in the powerpoint file lect12-01.ppt (available on the class web page).
Unfortunately, the basic code for the indexed binary search tree must be modified to make the algorithm for finding the crossing table work. In particular, the entry for the k-table for some index i is calculated by adding up the leftSize values for every node whose right child is visited. The code provided by Sahni does not return this value (since you would normally not need to access it if you're using an iBST). Thus, you'll have to modify the code to make it work. There are several approaches to this modification, two of which are:
Last Modified: 27 October 2001
THIS PAGE MAINTAINED BY: John Barr, Ithaca College