2 then return TREE-MINIMUM (right[x])// if the node x has a right child , simply return that , that is the successor.
//now is the tricky part .. there is no node as the right child,
traverse back along the parent path , which ever node along the path has a right childe is the successor
3 y ← p[x]// y <- parent of x
4while y ≠ NIL and x = right[y]// as long as y is not nil and the current node is the right child , we keep going to the top, if it is the left child , we simply return the parent y.
5do x ← y // make the parent as the current node.
6 y ← p[y]// fetch the parent of the current node just set.
7return y // this will return either NIL , if we shoot past the root of the tree or we are not the right child of the parent , left child implies this node will be the successor.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.