CS 112
Homework 9

Notice different deadline: Monday April 18, by midnight.


Design, implement and test a Java class called BinaryTree which implements an abstract data type for a binary tree, as started in class on Thursday and continued on Tuesday and next Thursday.
Extend it to a new class called BinSearchTree for binary search trees. Details below.

Notice the detailed timeline I am enforcing, to make sure that you get started in time, and get a part of the homework done before each of the following two classes. In each class, a slightly more advanced technique will be explained, and you will have difficulty understanding it if you have not worked on the previous part of the homework.

Final submission (changing permissions on the java files) is due on Tuesday April 19, before class.


The basic node data structure was discussed in class, and consists in a data field and two links to the left and right subtrees.

The tree class should allow insertion and deletion of leaves and subtrees, and navigation in the tree.
The class should contain the following functions:

Extension (to be done next week, on Tuesday and Thursday)
The Binary Search Tree class should also contain a function to create a binary search tree starting from an array, to search for a value in the tree and to sort.

You should come up with the best solution you can for this implementation. Then you should discuss your solution with me in next Tuesday's lab to check that it is sound, before embarking (next week) on the implementation.

The final program should be a self contained applet, with an applet graphical interface.


Grading guide

Ileana Streinu