return true/end delete(notice that this is--finally--the end of the delete(routine let' review the code for these two stepsstep if the node to be deletedcurrentis the rootit has no parent so we merely set the root to the successor otherwisethe node to be deleted can be either left or right child (figure shows it as right child)so we set the appropriate field in its parent to point to successor when delete(returns and current goes out of scopethe node referred to by current will have no references to itso it will be discarded during java' next garbage collection step we set the left child of successor to point to current' left child what happens if the successor has children of its ownfirst of alla successor node is guaranteed not to have left child this is true whether the successor is the right child of the node to be deleted or one of this right child' left children how do we know thiswellremember that the algorithm we use to determine the successor goes to the right child first and then to any left children of that right child it stops when it gets to node with no left childso the algorithm itself determines that the successor can' have any left children if it didthat left child would be the successor instead you can check this out on the workshop applet no matter how many trees you makeyou'll never find situation in which node' successor has left child (assuming the original node has two childrenwhich is the situation that leads to all this trouble in the first placeon the other handthe successor may very well have right child this isn' much of problem when the successor is the right child of the node to be deleted when we move the successorits right subtree simply follows along with it there' no conflict with the right child of the node being deleted because the successor is this right child in the next section we'll see that successor' right child needs more attention if the successor is not the right child of the node to be deleted successor is left descendant of right child of delnode if successor is left descendant of the right child of the node to be deletedfour steps are required to perform the deletion plug the right child of successor into the leftchild field of the successor' parent plug the right child of the node to be deleted into the rightchild field of successor