Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have the following binary search tree. Perform the following operations on t

ID: 3565407 • Letter: Y

Question

You have the following binary search tree.

Perform the following operations on the tree.

a)insert 12

b)insert 13

c)insert 9

d)remove 32

e)remove 21

f)remove 45

g)insert 30

h)insert 66

i)remove 65

j)remove 11

The operations must be applied consecutively one after another.(Please Show Steps, thank you)

You have the following binary search tree. Perform the following operations on the tree. a)insert 12 b)insert 13 c)insert 9 d)remove 32 e)remove 21 f)remove 45 g)insert 30 h)insert 66 i)remove 65 j)remove 11 The operations must be applied consecutively one after another.(Please Show Steps, thank you)

Explanation / Answer

1) insert 12 -> 12 will become left child of 19.
2) insert 13 -> 13 will become right child of 12.

3) insert 9 -> 9 will become right child of 5.
4) remove 32 -> since 32 has both right and left child to delete 32, replace 32 with smallest element on right subtree of 32. so 32 will be replaced by 45. now 32 has right child 63 and left child null . replace 32 and 63 and remove 32 from the tree.

5) remove 21 -> 21 has null left and right child so remove it directly.
6) remove 45 -> same as the case of remove 32 , 45 is replace by 63 i.e 63 is new root and remove 45.
7) insert 33 -> 33 will become right child of 22.
8) insert 66 -> 66 become left child of 67.
9) remove 65 -> smallest element in right subtree is 66 so replace 65 with 66 and remove 65.
10) remove 11 -> replace 11 by 9 and remove 11.



Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote