Find the Minimum and Maximum Value in a Binary Search Tree
In this challenge you will define two methods, findMin
and findMax
. These
methods should return the minimum and maximum value held in the binary search
tree (don't worry about adding values to the tree for now, we have added some in
the background). If you get stuck, reflect on the invariant that must be true
for binary search trees: each left subtree is less than or equal to its parent
and each right subtree is greater than or equal to its parent. Let's also say
that our tree can only store integer values. If the tree is empty, either method
should return null
.
Test
{{test}}Console output