2、程序源代码:
public class SimiliarTreeTest {
public static boolean test(BinNode t1,BinNode t2){
if(t1==null&&t2==null)
return true;
else if(t1!=null&&t2!=null)
{
return test(t1.left,t2.left)&&test(t1.right,t2.right);
}
return false;
}
}
3、测试类:
public class SimiliarilityTest {
public static void main(String[] args){
BST intTree=new BST();
BST charTree=new BST();
BST strTree=new BST();
Integer[] numbers={14,15,2,26,36,11,25,58,47,44,16,1};
Character[] chars={14,15,2,26,36,11,25,58,47,44,16,1};
String[] strs={"this","is ","so ","dispointed","and ","i ","am","trying"};
for(int i=0;i |