Update bst.py

This commit is contained in:
marina 2023-08-03 13:13:18 -07:00 committed by GitHub
parent a2dce9493e
commit 51e6497cef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,11 +25,11 @@ class Node(object):
def search(self, item):
if self.value == item:
return True
found = False
if (self.left and self.left.search(item)) or \
(self.right and self.right.search(item)):
found = True
return found
return True
return False
def preorder(self):
yield self.value