Question: EXISTING CODE class BinaryTree: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right def insert_left(self, new_data): if self.left == None:

 EXISTING CODE class BinaryTree: def __init__(self, data, left=None, right=None): self.data =

EXISTING CODE

class BinaryTree: def __init__(self, data, left=None, right=None): self.data = data self.left = left self.right = right

def insert_left(self, new_data): if self.left == None: self.left = BinaryTree(new_data) else: t = BinaryTree(new_data, left=self.left) self.left = t

def insert_right(self, new_data): if self.right == None: self.right = BinaryTree(new_data) else: t = BinaryTree(new_data, right=self.right) self.right = t

def get_left(self): return self.left

def get_right(self): return self.right

def set_data(self, data): self.data = data

def get_data(self): return self.data

def set_left(self, left): self.left = left

def set_right(self, right): self.right = right

Define a function named is_full (my_tree) which takes a binary tree as a parameter and returns True if the given tree is full, and False otherwise. A full binary tree is defined as a binary tree in which all nodes have either zero or two child nodes. Conversely, there is no node with only one child in a ful binary tree. For example, consider the following binary tree: 41 The result is False (node 29 has only one child). Notes: - You cannot reuse the is_full_node() method developed in Q4 as you need to differentiate between the case where a node has no child and the case where a node has 2 children. - A BinaryTree implementation is provided to you as part of this exercise - you should not define your own BinaryTree class. Instead, your code can make use of any of the BinaryTree ADT data fields or methods. For example: Answer: (penalty regime: 0,0,5,10,15,20,25,30,35,40,45,50% )

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!