You are viewing a single comment's thread. Return to all comments →
Python 3 version:
def checkBST(n, min=0, max=10000):
if not n:
if n.data <= min or n.data >= max:
return checkBST(n.left, min, n.data) and checkBST(n.right, n.data, max)
I have simplified the above "clean" Java solution to make a singular function. It is inline with my initial algorithm, but less than 1/3 of the code (was a conglomorated mish-mosh of extra checks and functions to perform them).