Question: Write an algorithm that returns the second largest value for a binary search tree containing at least two nodes. Assume the binary search tree does
Write an algorithm that returns the second largest value for a binary search tree containing at least two nodes. Assume the binary search tree does not allow duplicates. Give the time complexity of your algorithm.
Write a method int height() inside the BinarySearchTree.java. The height of a binary tree is the length of the path from the root to the deepest leaf.
Write a method in the BinarySearchTree.java to display all of the root to leaves paths. The signature of the method will be as follows: public void printPaths(){} The method should print each path on a separate line where info on each node is separated by comma.
Ex: For the BST below, the paths would be as following:
5, 4, 11, 7
5, 4, 11, 2
5, 8, 13
5, 8, 4, 1
Write a method in the BinarySearchTree.java to return the reverse of the binary search tree. The returned binary tree should be the mirror image of the binary tree whose root is at this binary tree. Every node in the new binary tree will have its children in reverse order i.e., left child takes the place of right child and right child becomes left child. The signature of the method will be as follows : public BinarySearchTree
4 / \ 2 5 / \ 1 3
is changed to... 4 / \ 5 2 / \ 3 1
Thank you
5-8-41 5-4-11-7 1 /1_2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
