boolean areMirrors(BinaryTreeNode root1,BinaryTreeNode root2){
if(root1 == null && root2 == null)
return true;
if(root1 == null || root2 == null)
return false;
if(root1.getData() != root2.getData())
return false;
else
return areMirrors(root1.getLeft(),root2.getRight())
&& areMirrors(root1.getRight(),root2.getLeft());
};
给定两棵树,判断它们是否互为镜像
最新推荐文章于 2021-11-29 16:43:43 发布