Question: Python 3 Programming Create the code in class on Binary Tree (BT) to enable user to insert some nodes (Root/Right/Left Child), getSize of the tree(),

Python 3 Programming
Create the code in class on Binary Tree (BT) to enable user to
insert some nodes (Root/Right/Left Child),
getSize of the tree(),
height and depth of a given node(),
IsInternal node(),
IsExternal node()
CoutrightChild of any given node(),
CountleftChild of any given node(),
num children of a given node ()
delete node()
Find a given target node from the list of nodes().
*The example code as in the attached picture.
 Python 3 Programming Create the code in class on Binary Tree

"""node class is superclass, BSTree is subclass" class Node (object): def -init-(self,info): self.info = info self.left None self.rightNone class BSTree (object): EXAMPLE ONLY def init (self): self.root None def create(self,value): if self.root == None : sel f . root Node ( value ) else: currentself.root while 1: if value current.info: current current.right else: current.right # Node (value) break def inorder (self,node): if node is not None: self.inorder (node.left) print (node.info) self.inorder (node.right) myTree BSTree () array [0,3,1,6,4,7,10,14,13] for i in array: myTree.create(i) print( "data =", array) print("in order transversal") myTree.inorder (myTree.root)

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!