question archive For the following binary search tree, show the result of following operations (Please follow the algorithm from the lecture/textbook): 8 /\ 4 16 /\ 9 19 /\ 17 22 a) Insert key 20; b) Delete 8 from the result of a); c) Delete 19 from the result of b); d) Delete 16 from the result of c)

For the following binary search tree, show the result of following operations (Please follow the algorithm from the lecture/textbook): 8 /\ 4 16 /\ 9 19 /\ 17 22 a) Insert key 20; b) Delete 8 from the result of a); c) Delete 19 from the result of b); d) Delete 16 from the result of c)

Subject:Computer SciencePrice:9.82 Bought3

For the following binary search tree, show the result of following operations (Please follow the algorithm from the lecture/textbook):

8 /\ 4 16 /\ 9 19 /\ 17 22

a) Insert key 20;

b) Delete 8 from the result of a);

c) Delete 19 from the result of b);

d) Delete 16 from the result of c).

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Binary Search tree:

A binary search tree is a tree in which the value of the left subtree is less than the value of its parent node and the value of right subtree is greater than or equal to its parent node.

 

The solution of all parts is given below in explanationsection.

Step-by-step explanation

a) Insertion of Key 20:

 Because this question can not be solved here, I am attaching pictures of answers after solving on the register.

a) Insert hey 20 "Because 20 is greater root node so it will go toward rightsubtree. J (i ) 20 is greater than 16 So it will go toward right 296 - subree ill ) 20 is greater than 19 so it will go again toward right subtree 22 Because 20 is less than 22 so it will toward lett subtree of 22.

b) Delete 8 from result a

After deleting '8', '4' will become root node of this binary search tree solution is given in this picture.

b) Delete 8 Jom result of result O J = ) Before After 5 Deleting Explanation: - 20 STRESS i) Because 8 is root nod and it has two child aly which is lead Node b) 16 which is non-lead node i) After deleting '8' y will become root node. This method is "in order Pre-decessor"

c) Delete 19 from result of b:

Because 19 is non-leaf node and it has two children node 17 and 22.

To delete 19 go toward right subtree of 19 and select smallest leaf node.

Solution is given on this picture.

() Delet 19 from the result of b. Result of b y - Before 19 patter Deleting 17 20 Explanation: ") Because 19 is non-leat node or hey, and it has two children node. 70 toward right-sub tree and select smalles lead node which is '20' and replace it with 19. After Deleting 19:- 9 17 22

d) Delete 16 from result of c:

 Because 16 is a non-leaf node and it has two children node 9 and 20.

To delete 16 go toward left subtree of 16 and select smallest leaf node. because 9 is the only leaf node on the left sub-tree of 16 so, replace 9 with 16.

Solution is given on this picture.

Result of ci- 6 a) No improv 0151 9 He was weary tajisn't he (b)wasn't he do ()doesn't he (d)No impro Q152 What you h 17 workshop =) After Deleting (a]have yo 22 (b)you ha ()have y (d)No imp It from result of C 0153. Keats say poems (a)speak (b) des (c) expr (d)No Q154 The en (a)ret (b)ret (c)ret (d)N Q15 No 17 22 I hope you like it kind wishes

All pictures are in attached file

Please see the attached file