You are viewing a single comment's thread. Return to all comments →
Hi, I can't see why my solution is wrong, it looks pretty similar. If anyone has an idea...
def check_binary_search_tree_(root): if (root is None): return True elif (root.left is None) and (root.right is None): return -float('inf')<root.data<float('inf') elif (root.left is None): return (root.right.data>root.data) and check_binary_search_tree_(root.right) elif (root.right is None): return (root.left.data<root.data) and check_binary_search_tree_(root.left) else: return (root.left.data<root.data) and (root.right.data>root.data) and check_binary_search_tree_(root.right) and check_binary_search_tree_(root.left)
Seems like cookies are disabled on this browser, please enable them to open this website
Trees: Is This a Binary Search Tree?
You are viewing a single comment's thread. Return to all comments →
Hi, I can't see why my solution is wrong, it looks pretty similar. If anyone has an idea...