I am trying to solve the following problem:
Return the root of a binary search tree t modified to contain only values <= k. (Using the normal BST class where we have an item,left and right)
def prune(t,k):
if not t:
return None
if k < t.item
while t.item > k:
t = t.left
return t
I think I am doing it completely wrong.. Maybe there is some easy recursive way to do it?