Question: Implement the following methods in the Binary Tree class: height(root) method that will return the height of the binary search tree. search(element) method that performs

Implement the following methods in the Binary Tree class:

height(root) method that will return the height of the binary search tree.

search(element) method that performs the binary search for a specific element in the Binary Search Tree.

inOrder(root) method to print the elements in the tree in an inOrder sequence. Do not use recursion.

preorder(root) method to print the elements in the tree in an inOrder sequence. Use recursion.

delete(v) method that will delete a specific element in the tree.

internalCounter(root) method that returns the number of internal nodes in the binary search tree.

Write a BinaryTreeTester class to test your code by creating a Binary Search Tree.

Ask the user to enter 10 integer elements.

Print the size of the tree.

Print the height of the tree.

Print the trees elements in inOrder sequence.

Print the trees elements in preOrder sequence.

Ask the user for an element to be deleted from the tree, then use the delete method to delete that element.

Print the number of internal nodes in the tree using the internalCounter method.

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 Databases Questions!