Question: 1 . Add two methods getSmallest and getLargest to LinkedBST. getSmallest should return the smallest element in the tree and getLargest should return the largest
Add two methods getSmallest and getLargest to
LinkedBST. getSmallest should return the smallest
element in the tree and getLargest should return the
largest element in the tree.
Note: To improve efficiency, both methods should check the
least amount of Nodes required to arrive at the answer. In
other words, you should not traverse the entire tree to find
the smallest and largest elements.
Add a height method to BinaryNode which returns its
height. You can calculate this recursively by the following
recursive equation:
The height of a Node is the height of its tallest subtree.
The height of None is
After BinaryNode has a height method, add a height
method to LinkedBST which returns the height of the
entire tree ie simply call height on the root Node and
return its return value
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
