Answered step by step
Verified Expert Solution
Question
1 Approved Answer
.p is referring to the parent of the node procedure Transplant(T,u,v) if u.p == NIL T.root = v else if u == u.p.left u.p.left =
.p is referring to the parent of the node procedure Transplant(T,u,v) if u.p == NIL T.root = v else if u == u.p.left u.p.left = v else u.p.right = v if v != NIL v.p = u.p
procedure TreeDelete(T,z) if z.left == NIL Transplant(T,z,z.right) else if z.right == NIL Transplant(T,z,z.left) else y = TreeMinimum(z.right) if y.p != z Transplant(T,y,y.right) y.right = z.right y.right.p = y Transplant(T,z,y) y.left = z.left y.left.p = y
Problem 77. Let T be the following tree. Starting with this tree, show the result of TreeDelete(T,z1) followed by TreeDelete(T,z2). Similarly, show the result of TreeDelete(T,z2) followed by TreeDelete(T,z1). Do the results differ?
z1 / \ a z2 / \ b c \ / \ d e f
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started