To find the successor of x in a BST

View previous topic View next topic Go down

To find the successor of x in a BST

Post  Admin on Mon Sep 12, 2011 3:14 pm

The last left turn is the successor(x):

public E successor(E x){
return succAux(root, x, null);
}

public E succAux(Node root, E x, E best){
if(root==null)
return best;
int c=x.compartTo(root);
if(c>0)
return succAux(root.right, X, best);
else
return succAux(root.l, X, root.v);
}

Admin
Admin

Posts : 131
Join date : 2011-08-16

View user profile http://codefornongeek.forumotion.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum