You are viewing a single comment's thread. Return to all comments →
Thanks. Python 3 version:
import sys def check(root, min, max): if root == None: return True if root.data <= min or root.data >= max: return False return check(root.left, min, root.data) and check(root.right, root.data, max) def check_binary_search_tree_(root): return check(root, float('-inf'), float('inf'))
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 →
Thanks. Python 3 version: