Question: 1 . Consider the binary tree class presented in the lectures. class BinaryTree: class _ Node: def _ _ init _ _ ( self ,
Consider the binary tree class presented in the lectures. class BinaryTree: class Node: def initselfvalue,leftNone,rightNone: self.valuevalue self.leftleft self.rightright def initself: self.rootNone def addrootselfval: self.rootself.Nodeval def isEmptyself: return self.rootNone def attachselft t: if tNone: self.root.lefttroot if tNone: self.root.righttroot a Draw the binary tree b constructed as a result of running the following main function. def main: bBinaryTree baddroot bBinaryTree baddroot bBinaryTree baddroot battachbb bBinaryTree baddroot battachbNone b Implement the recursive method search as per the documentation below. What is the time, extra space, and total space cost of your method? Do not count the stack frame space. def sea
rchselfval: Search for value val in binary tree Pre: object is a BinaryTree Post: object is not modified Return: True if val exists in object, False otherwise c Implement the recursive helper method recfindsmallest as per the documentation. #return the smallest value in a BinaryTree #pre: object is a BinaryTree instance whose elements are numeric #post: object has not been modified #return value: smallest value in object's elements or None if tree is empty def findsmallestself: leastself.recfindsmallestselfroot printsmallest value in tree is: least
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
