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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started