Question: 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.

Modify the algorithm TREE-DELETE so that when the node z to be

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 return

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!