Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hey I need help with this question I have added the BinarySearchTree class below It is in python An implementation of the BinarySearchtree ADT is
Hey I need help with this question I have added the BinarySearchTree class below It is in python
An implementation of the BinarySearchtree ADT is shown in the answer box for this question. Extend the BinarySearchtree class by adding the method search(self, value) which takes a value as a parameter. This method should search for the parameter value in the binary search tree. If the value is found, the method should return the found object, and None otherwise. Note: submit the entire class definition. For example: Test Result 9 None node = tree1. search (9) if not isinstance(node, BinarySearchTree): print('The search method must return an object of BinarySearchTree') print(node.get_data()) print(treel. search(0)) None tree = BinarySearchTree (15) print(tree. search (99)) print(tree. search (299)) None 1. class BinarySearchTree: 2 def __init__(self, data, left=None, right=None): 3 self.__data data 4 self.__left left 5 self.__right right 6 7 def get_left(self): 8 return self.__left 9 10 def get_right(self): 11 return self.__right 12 def set_left(self, left): 14 self.__left = left 15 16 def set_right(self, right): 17 self.__right right 18 19 def set_data(self, data): 20 self.__data data 21 22 def get_data(self): 23 return self.__data 13 7
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started