标签:style class blog code http color
题目:
输入一个二叉树,输出其镜像。
BinTreeNode* ReverseTree(BinTreeNode* pRoot) { if (pRoot == NULL) return NULL; BinTreeNode* pLeftReverse = ReverseTree(pRoot->left); BinTreeNode* pRightReverse = ReverseTree(pRoot->right); pRoot->left = pRightReverse; pRoot->right = pLeftReverse; return pRoot; }
根节点不变,递归交换其左右子树
剑指offer (19) 二叉树镜像 对称二叉树,布布扣,bubuko.com
标签:style class blog code http color
原文地址:http://www.cnblogs.com/wwwjieo0/p/3785814.html