Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ Node is defined as
- class node:
- def __init__(self, data):
- self.data = data
- self.left = None
- self.right = None
- """
- def check_binary_search_tree_(root, values = None):
- #print root.data
- #print root.left
- #print root.right
- toReturn = True
- if values == None:
- values = dict()
- if not root.data in values:
- values[root.data] = True
- else:
- return False
- if (root.left):
- if (root.left.data > root.data):
- return False
- else:
- toReturn = check_binary_search_tree_(root.left)
- if (root.right):
- if (root.right.data < root.data):
- return False
- else:
- toReturn = check_binary_search_tree_(root.right)
- return toReturn
Advertisement
RAW Paste Data
Copied
Advertisement