Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3 1. The class BST describes a node in a binary search tree. Trace the execution of the following program that builds a binary

Python 3 image text in transcribed
1. The class BST describes a node in a binary search tree. Trace the execution of the following program that builds a binary search tree. class BST (object): # Constructor def init..(self, item, left-None,right-None): self.item -item self.left left self.right right def Insert (T,nevItem): if T None: elif T.item nevItem: else: . BST(newItem) T.left Insert (T.left,novItem) T.right Insert (T.right,newItem) return T T None A [70. 50, 90, 130, 150, 40, 10, 30. oo] for a in A: T- Insert (T,a) 2. Write a function that prints all the keys in a binary search tree in ascending order given a reference to its root. 3. Write a function that receives a reference to the root of a binary search tree and returns a reference to the node that contains the smallest item in the tree. contains the largest item in the tree. to the node where k is, or None if k is not in the tree. 4. Write a function that receives a reference to the root of a binary search tree and returns a reference to the node that 5. Write a function that receives in integer k and a reference to the root of a binary search tree and returns a reference 6. Write a function that receives a reference to the root of a binary search tree and returns the number of nodes in the 7. Write a function that returns the height of a binary search tree given a reference to its root. tree

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

Step: 3

blur-text-image

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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Understand why customers complain.

Answered: 1 week ago