Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed
"""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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions