Skip to content

Instantly share code, notes, and snippets.

@lettergram
Created March 14, 2015 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lettergram/5adfd16ff0518548a386 to your computer and use it in GitHub Desktop.
Save lettergram/5adfd16ff0518548a386 to your computer and use it in GitHub Desktop.
Search key in BST
'''
Discovers if a 'key' is present in the binary tree
'''
def find(self, root, key):
if root is None or root.data is key:
return root
elif key < root.data:
return self.find(root.left, key)
else:
return self.find(root.right, key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment