Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python3 Consider the binary search tree shown in class. We defined create functi

ID: 3594516 • Letter: P

Question

Python3

Consider the binary search tree shown in class. We defined create function to return a newly created tree node storing the given item, and add function that adds an item to the given binary search tree, as following

Define find function that returns True if the given item is in the tree, False otherwise. For this problem, you must use recursion as in the add function above.

def find(tree, item):

# fill out this part

def create (item) : return [item , None , None] # [data, left-sub-tree, right-sub-tree] def add (tree, item); e, left, right tree if e == item: return False elif e

Explanation / Answer

def find(tree, item):
e, left, right = tree
if e == item:
return True
else if e < item:
if right == None:
return False
else:
return find(right, item)
else:
if left == None:
return False
else:
return find(left, item)

# copy pastable code link: https://paste.ee/p/5zbs0