Question: Program a binary search tree ( BST ) in Java by implementing the interface given below. public interface BinaryTree < E extends Comparable

Program a binary search tree ("BST") in Java by implementing the interface given below.
public interface BinaryTree< E extends Comparable>
(
public void insert (E item); //inserts an E item to the BST
public void delete (E item);// deletes the E item
public boolean find(E item; // returns true if E item exist, else return false
public int treeHeight (): //returns the height of the BST
public int itemHeight (E item); // returns the height of the E item, else return -1
public int leftHeight (E item); //returns the height of the left subtree of E item
public int rightHeight (E item)://returns the height of the right subtree of E item
public boolean isleaf (E item); //returns true if E item is a leaf node else false
public int status (E item); //retun 0 if root, 1 if left child, 2 if right child
public void display (); //prints out the contents of the BST in descending order
)
The BST must have the following properties: (1) for any unique value x and y, either x is less than y or y is less than x; and (2) for any node in the BST, the key stored is greater than any key in its left subtree and less than any key in its right subtree. For the delete method, use the successor to for case 3. For both the leftHeight and rightHeight method, an empty/null subtree has a height of -1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!