Question: Consider the binary search tree built by inserting the following sequence of integers, one at a time: 5 , 4 , 7 , 9 ,

Consider the binary search tree built by inserting the following sequence of integers,
one at a time: 5,4,7,9,8,6,2,3,1
Which method below will properly remove node 4 from the binary search tree?
Find the in order predecessor (IOP) of node 4, which is node 3. Remove node 3.
from the tree by setting the right pointer of its parent (node 2) to point to the node
pointed to by the left pointer of node 3. Then copy the key and any data from
node 3 to node 4, turning node 4 into a new node 3, and delete the old node 3.
Set the left pointer of node 5 to nullptr, and then delete node 4.
Find the in order predecessor (IOP) of node 4, which is node 3. Remove node 3
from the tree by setting the right pointer of its parent (node 2) to nullptr. Then
copy the key and any data from node 3 to node 4, turning node 4 into a new node
3, and delete the old node 3.
Set the left pointer of node 5 to point to the node pointed to by the left pointer of
node 4, and then delete node 4.
Consider the binary search tree built by

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!