Answered step by step
Verified Expert Solution
Link Copied!

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 pythonimage text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions