Get the left sum of the BST! FIND THE LEFT SUM OF THE BST! By…
Question Get the left sum of the BST! FIND THE LEFT SUM OF THE BST! By… Get the left sum of the BST! FIND THE LEFT SUM OF THE BST! By basically finishing the functions in the bold. import sysclass Queue(object): def __init__(self): self.queue = [] # add an item to the end of the queue def enqueue(self, item): self.queue.append(item) # remove an item from the beginning of the queue def dequeue(self): return (self.queue.pop(0)) # check if the queue is empty def is_empty(self): return (len(self.queue) == 0) # return the size of the queue def size(self): return (len(self.queue))class Node (object): def __init__ (self, data): self.data = data self.lchild = None self.rchild = Noneclass Tree (object): def __init__ (self): self.root = None # insert data into the tree def insert (self, data): new_node = Node (data) if (self.root == None): self.root = new_node return else: current = self.root parent = self.root while (current != None): parent = current if (data < current.data): current = current.lchild else: current = current.rchild # found location now insert node if (data < parent.data): parent.lchild = new_node else: parent.rchild = new_node # ***There is no reason to change anything above this line*** def get_height (self):# Add your code here! def get_level (self, level):# Add your code here! # Returns an integer for the left sum of the BST def get_left_sum(self):# Add your code here!# ***There is no reason to change anything below this line***def main(): # Create tree line = sys.stdin.readline() line = line.strip() line = line.split() tree_input = list (map (int, line)) # converts elements into ints tree = Tree() for i in tree_input: tree.insert(i) print(tree.get_left_sum())if __name__ == "__main__": main() FILL THESE OUT! 1) def get_height (self):# Add your code here!2) def get_level (self, level):# Add your code here!3) # Returns an integer for the left sum of the BST def get_left_sum(self):# Add your code here! Computer Science Engineering & Technology Python Programming CSCI 1310 Share QuestionEmailCopy link Comments (0)


