In algorithms/python, implement the search method below for BinarySearchTree class:
class Node:
def __init__(self, data):
self.data = data
self.left_child = None
self.right_child = None
class BinarySearchTree:
def __init__(self):
self.root_node = None
...
...
# method returns True if data found, False otherwise
def search(self, data):
#### IMPLEMENT THE BODY OF THIS METHOD #########
# method returns True if data found, False otherwise
def search(self, data):
current = self.root_node
while current:
if data == current.data:
return True
elif data < current.data:
current = current.left_child
else:
current = current.right_child
return False
In algorithms/python, implement the search method below for BinarySearchTree class:
class Node:
def __init__(self, data):
self.data = data
self.left_child = None
self.right_child = None
class BinarySearchTree:
def __init__(self):
self.root_node = None
...
...
# method returns True if data found, False otherwise
def search(self, data):
#### IMPLEMENT THE BODY OF THIS METHOD #########
In algorithms/python, implement the search method below for BinarySearchTree class:
class Node:
def __init__(self, data):
self.data = data
self.left_child = None
self.right_child = None
class BinarySearchTree:
def __init__(self):
self.root_node = None
...
...
# method returns True if data found, False otherwise
def search(self, data):
#### IMPLEMENT THE BODY OF THIS METHOD #########
# method returns True if data found, False otherwise
def search(self, data):
current = self.root_node
while current:
if data == current.data:
return True
elif data < current.data:
current = current.left_child
else:
current = current.right_child
return False
status | not learned | measured difficulty | 37% [default] | last interval [days] | |||
---|---|---|---|---|---|---|---|
repetition number in this series | 0 | memorised on | scheduled repetition | ||||
scheduled repetition interval | last repetition or drill |