Code For NonGeek
Would you like to react to this message? Create an account in a few clicks or log in to continue.

To find the successor of x in a BST

Go down

To find the successor of x in a BST Empty To find the successor of x in a BST

Post  Admin 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

https://codefornongeek.forumotion.com

Back to top Go down

Back to top

- Similar topics

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