剑指offer27.二叉树的镜像 P157
题目:请完成一个函数,输入一个二叉树,该函数输出它的镜像。
// 其实就是先根遍历的模板,在左右子树递归访问前交换左右子树
void MirrorRecursively(BinaryTreeNode
*pNode
) {
if (pNode
== NULL) return;
if (pNode
-> left
== NULL && pNode
-> right
== NULL) return ;
BinaryTreeNode
*temp
= pNode
-> left
;
pNode
-> left
= pNode
-> right
;
pNode
-> right
= temp
;
if (pNode
-> left
)
MirrorRecursively(pNode
-> left
);
if (pNode
-> right
)
MirrorRecursively(pNode
-> right
);
}