Question: 1. (10 points): You are given a binary search tree (BST) consisting of N nodes that store integers as elements. Assume that you have

1. (10 points): You are given a binary search tree (BST) consisting 

1. (10 points): You are given a binary search tree (BST) consisting of N nodes that store integers as elements. Assume that you have access to the BSTNode and the BST class with the following methods. 1 private class BSTNode { 2 private int id; 3 private BSTNode left; 4 private BSTNode right; 5 public BSTNode (int key, BSTNode 1, BSTNode r) { id = key; left = 1; right r; 6 7 8 9 } 4 1 2 public class BST implements BSTinterface { 3 5 6 7 } 8 9 } = public void insert (int id); public void remove(int id); public void search (int id); public void printall (); int height (); public public void show(); (a) Write a method findMin for the class BST above that returns the element with the minimum value in the BST. (b) Write a method findMax for the class BST above that returns the element with the maximum value in the BST. (c) Analyze the running times of findMin and findMax methods for the best case and the worst case. Explain your answer with a picture.

Step by Step Solution

3.35 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here are the methods for findMin and findMax The minimum value will be the left most node of the tre... View full answer

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!