Objectives and Overview: Binary search trees can provide an efficient vehicle for searching, provided that they are well-balanced. However, the guarantee of balance in a binary search tree is not automatic-in the worst case, a search of an n-element binary search tree is O(n) in complexity. The idea of a splay tree can be used to redefine the add and remove functions in such a way that the tree remains better balanced. This lab suggests an experiment that will allow you to compare the efficiency of search using binary search trees and splay trees. You should be familiar with the relevant sections of Chapter 13 in your text before doing this lab.
On the CS210 (Tucker) server is a driver program called BTSearchDriver.java that you should drag to the desktop, along with a fresh copy of Assert.java (that's in the Source folder) and Structure.zip. Build a project called Lab9yourname.µ that looks like the one below:
Now run this program that builds a 1000-integer binary search tree and then searches for the integer 1001 in this tree.
Modify this program so that it uses the splay tree as a medium for storing integers, and rerun it for 1000 integers and a search for the integer 1001.
Submit your Java program from Part 2 of this lab by dragging it to the Drop Box folder. Also hand in a hard copy listing of your program, along with your answers to the questions in Parts 1 and 2.
Feel free to work on the programming part of this lab individually or in teams of two. But please complete the answers to the questions individually.