剑指offer28 . 对称的二叉树 P159
题目:请实现一个函数,用来判断一棵二叉树是不是对称的。如果一棵二叉树和它的镜像一样,那么它是对称的
bool judge(BinaryTreeNode
*proot1
, BinaryTreeNode
*proot2
) {
if (proot1
== NULL && proot2
== NULL) return true;
if (proot1
== NULL || proot2
== NULL) return false;
if (proot1
-> key
!= proot2
-> key
) return false;
return judge(proot1
-> left
, proot2
-> right
) && judge(proot1
-> right
, proot2
-> left
);
}
转载请注明原文地址: https://mac.8miu.com/read-505110.html