In this project, we will study binary search trees. To help you get started, we provide the following java code bst.zip which contains the implementations of normal binary search tree (treeNode.java), AVL tree (avltree.java), red-black tree (redblacktree.java), and splay tree (splaytree.java). Study these codes and have them run on your computer is the first step of your project.
You are asked to complete the following tasks:
public treeNode predecessor( int x ) public treeNode successor( int x )are not implemented. Please complete the implementation of both methods.
A recursive version of the insert and remove methods are given in treeNode.java. Please provide a non-recursive implementation of both the insert and remove methods and name the new methods as insert1 and remove1 (see find0 and find for an example of recursive and non-recursive implementations). Please create a method called question1 in the style of question0 in bst.java, to compare the performances of both recursive and non-recursive methods by running them on the same set of 500 examples with 5,000,000 mixed operations as shown in the method question0 (and used by test) in bst.java. Summerize the total running times for both cases and draw your conclusions from the experiment.
public int inorder(int i, int res)where i is the first position available in res, and the method inorder returns the next available position in res after it adds all the numbers in the subtree rooted by the current (this) node into res. In a similar way as in the method test, create another method in bst.java with the following interface:
public static void sort(int keys, int res, long times)which collects the running time of creating a binary search tree (i.e., avl, rbt, or spt), inserting all N keys in keys into the tree and collecting all numbers in the tree in the sorted order into res. Create 100 arrays of random numbers of size 500,000 to test the performance of each tree, summarize the total running time (the same set of arrays is used by each tree). You are asked to create the method question3 to contain the code for collecting running times in bst.java.
For all the tasks, please give a summary of your experiments and draw conclusions from the experimental data.
Submit everything in the ICON dropbox for Project 2 before the deadline.