Skip to content
Snippets Groups Projects
Commit 0efa61ba authored by Mohammed Ahmed's avatar Mohammed Ahmed
Browse files

Update bintree.py

parent eaee0d00
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,21 @@ class BST:
self._insert(data, cur_node.right)
else:
print("value is already in the tree")
def find(self, data):
if self.root:
is found = self.find(data, self.root)
if is_found:
return True
return False
else:
return None
def _find(self, data, cur_node):
if data > cur_node.data cur_node.right:
return self._find(data, cur_node.right)
elif data < cur_node.data cur_node.left:
return self._find(data, cur_node.left)
if data == cur_node.data:
return True
if __name__ == "__main__":
pass
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment