62,615
社区成员
发帖
与我相关
我的任务
分享
public class Node {
private Node left;
private Node right;
private int value;
public Node( Node left, Node right, int value ){
this.left = left;
this.right = right;
this.value = value;
}
public Node getLeft() { return left; }
public Node getRight() { return right; }
public int getValue() { return value; }
Node findNode( Node root, int value ){
while( root != null ){
int currval = root.getValue();
if( currval == value ) break;
if( currval < value ){
root = root.getRight();
} else { // currval > value
root = root.getLeft();
}
}
return root;
}
}