We will try to debug the following (pseudo) implementation of a recursive build. (Note to students: you can assume that ”Arceus” has been set as the ”root” value and that the function below is called with ”root” as your input for ”node”)

Buggy Code

def buildTree(node,new_data):
if new_data is "Stop":
delete first element of new_data return
else:
if node.right is None:
node.right becomes a new node with val = new_data[0] delete first element of new_data buildTree(node.right,new_data)
if node.left is None:
node.left becomes a new node with val = new_data[0] delete first element of new_data buildTree(node.left,new_data)
else: return