Homework 3B: Deleting from trees

Out: October 30, 2001
Due: November 13, 2001

Write a program that inserts and deletes in a binary tree. The tree is to be a tree of integers. Similar to how the linked list program worked, before insertion, check if the integer value to insert is already in the tree: if not, insert; if it is, delete.

Your print out should be clear: echo what number is to be inserted or deleted and print out the tree after each insert or delete. Here is an example:

> java TestDeleteTree
? 3
Inserting: 3
Tree:
3
   -
   -
? 2
Inserting: 2
Tree:
3
   -
   2
      -
      -
? 3
Deleting: 3
Tree:
2
   -
   -
? 2
Deleting: 2
Tree:
-
?

There is a class InputIntegers which I wrote which will do the reading of integers. We will also provide you with the following test suit. Test your program with this test suite and include some of your own tests.