Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. (20 Points) Use the TreeInsert () algorithm to insert the following keys: 9,2, 1, 5, 3, 4, 7, 6, 8, 14, 10,12,11,13,15 (in order)

image text in transcribed
image text in transcribed
image text in transcribed
5. (20 Points) Use the TreeInsert () algorithm to insert the following keys: 9,2, 1, 5, 3, 4, 7, 6, 8, 14, 10,12,11,13,15 (in order) into an initially empty BST. a. (10 Points) Draw the resulting BST. b. (10 Points) Use the Delete () algorithm to delete the following keys: 9,5,2 (in order) from the BST you drew in part (a), then draw the resulting tree. TreeMinimum (x) Pre: x1= NIL while x. left t=NIL x=x. eeft return x Transplant (T, u, v) if u.parent wi NIL T. root =v else if u un u,parent. left. i. parent. left = else u.parent. r ight =v if v i= NIL v.parent =u parent Delete (T,z) if z.left = NIL Tr case 1 or case 2.1 (right only) else if z.right= NIL (l case 2.2 (left only) else y= TreeMinimum (z.right) I/ case 3 if y.parent t=z Transplant (T, y,yright) y.right =2.right yright,parent=y Transplant (T,z,y). y. left =z.left y left.parent =y

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

How to reverse a Armstrong number by using double linked list ?

Answered: 1 week ago