We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ed5f7bc commit 392482cCopy full SHA for 392482c
27. validate-bst.py
@@ -0,0 +1,8 @@
1
+def validateBst(node, less_than=float('inf'), greater_than=float('-inf')):
2
+ if node is None:
3
+ return True
4
+ if greater_than <= node.value < less_than:
5
+ left_validation = validateBst(node.left, node.value, greater_than)
6
+ right_validation = validateBst(node.right, less_than, node.value)
7
+ return left_validation and right_validation
8
+ return False
0 commit comments