public boolean isTreesSame(BinaryTree T1, BinaryTree T2) {
if(T1==null && T2==null)
return true;
if(T1==null || T2==null)
return false;
if(T1.data==T2.data
&& isTreesSame(T1.left, T2.left)
&& isTreesSame(T1.right, T2.right))
return true;
return false;
}
No comments:
Post a Comment