""" Node is defined as
class node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
"""
def checknode(node,min,max):
if node == None:
return True
#print(node.data,min,max) min max被传递下去
if node.data<=min or node.data>=max:
return False
return checknode(node.left,min,node.data) and checknode(node.right,node.data,max)
def checkBST(root):
return checknode(root,float('-inf'),float('inf'))