Given the root of a binary search tree and 2 numbers min and max, trim the tree such that all the numbers in the new tree are between min and max (inclusive). The resulting tree should still be a valid binary search tree. So, if we get this tree as input: ___
___ and we’re given min value as 5 and max value as 13, then the resulting binary search tree should be: ___ ___ We should remove all the nodes whose value is not between min and max.
** Feel free to reference the lecture on Binary Search Tree for the node class, but what it more important here is the logic of your function. In which case your function should be in the form:**
def trimBST(tree,minVal,maxVal):
print tree.left # LeftChild
print tree.right # Right Child
print tree.val # Node's value
pass
# Use tree.left , tree.right , and tree.val as your methods to call
** There is no solution cell because the nature of the code should be more logical and a test would essentially give away the answer. Just focus your answer to fill out the logic of the solution using the methods described above **