-
-
Save amankharwal/5a8428215e93a27b9522d7d969e5f891 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class binarytree: | |
def __init__(self, val): | |
self.val = val | |
self.leftnode = leftnode | |
self.rightnode = rightnode | |
import sys | |
class BinarySearchTree: | |
def validate_BST(self, root: binarytree) -> bool: | |
return self.valid(root, sys.maxsize, -sys.maxsize) | |
def valid(self, root, max_, min_): | |
if root == None: | |
return True | |
else: | |
return False | |
return self.valid(root.leftnode, root.val, min_) and self.valid(root.rightnode, max_, root.val) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Aman, thank you for the 120 Python Projects. They are highly encouraging to keep learning.
In this solution there is no validation on the value structure of the Binary tree: left < root < right.
I believe the solution I propose works
Thank you again por posting the projects