Question: In Python, Link to Class: https://pastebin.com/42w6Tv0v Define a function called print insert position0 which takes a binary search tree as input, as well as a

In Python,

Link to Class: https://pastebin.com/42w6Tv0v

In Python, Link to Class: https://pastebin.com/42w6Tv0v Define a function called print insert

Define a function called print insert position0 which takes a binary search tree as input, as well as a value to be inserted into the tree. The function should not modify the tree at all -instead, it should simply print the position at which value would be inserted into the tree. This involves printing the node under which the value would be inserted, after either To the left of" or "To the right of If the data value to be inserted already exists in the tree, then the function should print "Duplicate The example code below makes use of the Binary Tree class: Class BinaryTree: def init_(self, data) self.data data self.left None self.right - None def insert left(self, new_data): if self.left None: self.left BinaryTree(new data) else: t BinaryTree(new_data) t.left-self.left self.leftt def insert right(self, new data): if self.rightNone: self.right BinaryTree(new_data) else: tBinaryTree(new_data) t.right-self.right self.right -t def get_left(self): return self.left def get_right(self): return self.right def set left(self, tree): self.left -tree def set_right(self, tree): self.right tree def set.data(self, data): self.data data def getdata self): return self.data For example: Test Result a-BinaryTree(100) print insert_positionCa, 29) To the left of 100 a -BinaryTree(50) a.insert_left (10) a.insert_left(20) a.insert left(30) a.insert.left(40) To the left of 10 print insert positionCa, 5)

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!