just another slight problem. I must also create an equals method for my IntTree class which cycles through two tree's and compares the nodes. If all of the values in the tree are equal, then it returns true, otherwise it returns false. Here is the code I have so far:
private boolean equals(IntTreeNode node1, IntTreeNode node2){
if ((node1 != null) || (node2 != null)){
if (node1.equals(node2)){
equals(node1.left, node2.left);
equals(node1.right, node2.right);
return node1.equals(node2);
}
}
return false;
}
When I call this method on my Driver program to compare two tree's that are exactly alike (blah1.equals(blah2)), I get false. However, when I call blah1.equals(blah1) I get true... I'm not sure if my return statement is correct either