All problems
BST Minimum and Maximum
Problem
Return the minimum and maximum values stored in a binary search tree built from the given values.
Insert the values in order (duplicates ignored), then walk left from the root to find the minimum and right to find the maximum.
Return [minimum, maximum], or [] when values is empty.
Hint
The minimum sits at the leftmost node and the maximum at the rightmost node.
Test cases
case 1
in: [[5,3,8,1]]
expected: [1,8]
case 2
in: [[7]]
expected: [7,7]
case 3
in: [[]]
expected: []
case 4
in: [[4,4,2]]
expected: [2,4]
Starter codePython
def bst_min_max(values):
# Your code here
pass4 test cases · run your code against them in the editor