After completing your binary search tree class run the following experiments on the class and record the results.

Create an empty binary search tree class and insert 1000 randomly generated Integer objects. 

Here is one way of doing this:

int n = 1000;
Random r = new Random();
BinarySearchTree b = new BinarySearchTree();
for(int i = 0; i < n; i++) {
    b.add( new Integer( r.nextInt() ) );
}

Record the time it takes to do this using the Stopwatch class. 

Record the height of the tree after inserting the 1000 items. 
Record the size of the tree. (It may not be 1000 because the random number generator may produce duplicates.). 
Run this experiment 10 times and note the average time to do the insertions, average height of the tree, and average size of the tree.

Repeat the experiment 10 times for the following values of N: 2,000, 4,000, 8,000, 16,000, 32,000, 64,000, 128,000, 256,000, 512,000, and 1,024,000. Record all information. (You can, of course, automate these experiments to save time.)

For each value of N what is the minimum possible tree height, assuming N unique values are inserted into the tree?

Repeat the experiment using random integers, but use the java TreeSet class. This class is in the java.util package. The documentation for the class is at

http://download.oracle.com/javase/6/docs/api/java/util/TreeSet.html

Use the Stopwatch class and do 10 experiments with 1000, 2,000, 4,000, 8,000, 16,000, 32,000, 64,000, 128,00, 256,000, 512,000, and 1,024,000 elements using the TreeSet.
What are the average times for TreeSet? How do they compare to your BinarySearchTree?

Next, Generate a list of 1000 integers sorted in ascending order. For example:

1, 2, 3, 4, ... 1000

Create an empty binary search tree class and insert the 1000 sorted integers into it. 
Record the height of the tree after inserting the 1000 items. 
Run this experiment 10 times and note the average time to do the insertions, average height of the tree (which you should be able to determine easily without calling the height method), and average size of the tree (again, you should be able to determine easily without calling the size method).

Repeat the experiment 10 times for the following values of N: 2,000, 4,000, 8,000, 16,000, 32,000, and 64,000., Predict how long it would take to add 128,000, 256,000, and 512,000 sorted integers into your binary search tree.

Repeat the experiment using integers in sorted order, but use the java TreeSet class.

For each experiment with TreeSet you just need to note the average time it takes to add the items. 
(The TreeSet class does not provide a way to get the height of the tree.) 

How do these times compare to the times it took for you BinarySearchTree class when inserting integers in sorted order? What do you think is the cause for these differences?