面试题27:二叉树的镜像

# -*- coding:utf-8 -*-
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None
class Solution:
    # 返回镜像树的根节点
    def Mirror(self, root):
        # write code here
        if root == None:
            return None
        
        # 处理根节点
        root.left, root.right = root.right, root.left
        # 处理左子树
        # 处理右子树
        self.Mirror(root.left)
        self.Mirror(root.right)

  

posted @ 2019-08-14 11:20  lililili——  阅读(181)  评论(0)    收藏  举报