Question: 1. In third case of deletion in binary search trees when node is to be deleted has both childs, node data is replaced with

1. In third case of deletion in binary search trees when node 

1. In third case of deletion in binary search trees when node is to be deleted has both childs, node data is replaced with its predecessor or successor. Let's say that we replace it with its successor. For finding successor, we studied the following algorithm SUCCESSOR(1) 1 if RIGHT(2) 2 3 else 4 5 6 7 8 return y null return BSTMIN(RIGHT (2)) y-PARENT(2) while y null and z = RIGHT(y) 2-y y-- PARENT(y) a. Provide a case when lines 4-7 are applicable to find the successor of a node. b. What will this code return when a node has no successor? Dry run this code with such an example. Note that parts a-b shouldn't be answered in context of deletion of nodes from the tree. c. Write down the scenario in tree deletion when statements in lines 4-7 are executed in order to replace the node deleted with its successor. Provide reason within two lines for such answer.

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 Programming Questions!