Created
June 5, 2018 09:10
-
-
Save shameemreza/27df2cc646bea93f9ba2ac97057472fe 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
# A utility function to search a given key in BST | |
def search(root,key): | |
# Base Cases: root is null or key is present at root | |
if root is None or root.val == key: | |
return root | |
# Key is greater than root's key | |
if root.val < key: | |
return search(root.right,key) | |
# Key is smaller than root's key | |
return search(root.left,key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment