/*
[二叉树的镜像]
[题目]
操作给定的二叉树,将其变换为源二叉树的镜像。
二叉树的镜像定义:
源二叉树
8
| |
6 10
| | | |
5 7 9 11
镜像二叉树
8
| |
10 6
| | | |
11 9 7 5
*/
#include <iostream>
#include <algorithm>
using namespace std;
struct TreeNode{
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
class Solution{
public:
void Mirror(TreeNode *pRoot){
if(pRoot == NULL)
return;
swap(pRoot->left, pRoot->right);
Mirror(pRoot->left);
Mirror(pRoot->right);
}
};
int main()
{
return 0;
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/15258.html