The code in Java:
private BiNode root = null;
//constructor
BST(int[] r) {
BiNode s = new BiNode(r[0], null, null);
test(root, s);
}
private void test(BiNode head, BiNode s){
head = s;
if (head != null)
System.out.println("head is not null");
if (root == null)
System.out.println("root is null");
}
Output:
head is not null
root is null
Why does root
not equal head
in the test
method?