node successor delnodenode current delnode rightchildwhile(current !nullsuccessorparent successorsuccessor currentcurrent current leftchild/go to right child /until no more /left children/go to left child /if successor not if(successor !delnode rightchild/right child/make connections successorparent leftchild successor rightchildsuccessor rightchild delnode rightchildreturn successorthe routine first goes to delnode' right child and thenin the while loopfollows down the path of all this right child' left children when the while loop exitssuccessor contains delnode' successor when we've found the successorwe may need to access its parentso within the while loop we also keep track of the parent of the current node the getsuccessor(routine carries out two additional operations in addition to finding the successor howeverto understand themwe need to step back and consider the big picture as we've seenthe successor node can occupy one of two possible positions relative to currentthe node to be deleted the successor can be current' right childor it can be one of this right child' left descendants we'll look at these two situations in turn successor is right child of delnode if successor is the right child of currentthings are simplified somewhat because we can simply move the subtree of which successor is the root and plug it in where the deleted node was this operation requires only two steps unplug current from the rightchild field of its parent (or leftchild field if appropriate)and set this field to point to successor unplug current' left child from currentand plug it into the leftchild field of successor