Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify the algorithm TREE-DELETE so that when the node z to be deleted has two children, the algorithm will choose node y as the predecessor
Modify the algorithm TREE-DELETE so that when the node z to be deleted has two children, the algorithm will choose node y as the predecessor instead of the successor of z. Make minimal but necessary changes to ensure the correctness of the algorithm.
TTREE DDELETE CTT, z) 1 if left [z NIL or right [zj NIL then y z else y FREE SUCCESSOR Cz 4 if left [y] NIL then x left else x right [y] if x. NIL. then p 1 I Dy if p [y] 1 O then root [T] 1 1 else if y left JJ then left IPL. 1 2 13 else right [p[y JJ 14 if y z then key Dz] keep Eyl 1 S 16 copy y's satellite data into z 17 returnStep 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