Question: python please The purpose of this laboratory is for you to demonstrate understanding of Binary Search Trees. The BinarySearchTree class definition is given as follows:

python please The purpose of this laboratory is for you to demonstrateunderstanding of Binary Search Trees. The BinarySearchTree class definition is given aspython please

The purpose of this laboratory is for you to demonstrate understanding of Binary Search Trees. The BinarySearchTree class definition is given as follows: class BinarySearchTree: def __init__(self, data, left=None, right=None): self.__data = data self._left = left self.__right = right def get_left(self): return self._left def get_right(self): return self._right def set_left(self, left): self. __left = left def set_right(self, right): self._right = right def set_data(self, data): self.__data = data def get_data(self): return self._data The print_tree() function is given as follows: def print_tree (tree, level): print(''* (level*4) + str(tree.get_data())) if tree.get_left() != None: print('(L)', end = '') print_tree(tree.get_left(), level + 1) if tree.get_right() != None: print('(R)', end = "") print_tree(tree.get_right(), level + 1) You will use the following binary search trees: 1 . tree1 = 27 14 35 10 19 31 42 . tree 2 = 10 14 . tree3 = 13 D P ( F K U tree4 = A E G NR Y An implementation of the BinarySearchTree ADT is shown in the answer box for this question. Extend the BinarySearch Tree 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 = treel. search (9) if not isinstance(node, BinarySearchTree) : print('The search method must return an object of BinarySearchTree') print(node.get_data()) print(tree1. search(0)) tree = BinarySearchTree (15) print(tree. search(99)) print(tree. search(299)) None None Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Reset answer 1 class BinarySearchTree: def _init__(self, data, left=None, right=None): self.__data data self.-_left = left self.__right = right def get_left(self): return self.__left def get_right(self): return self.__right def set_left(self, left): self. left = 'left def set_right(self, right): self.__right = right def set_data(self, data): self.__data data def get_data(self): return self.__data WISS WRFBorovorurawne

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!