博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【剑指offer python】面试题19:二叉树的镜像
阅读量:2382 次
发布时间:2019-05-10

本文共 503 字,大约阅读时间需要 1 分钟。

链接:

题目描述

操作给定的二叉树,将其变换为源二叉树的镜像。

输入描述:

二叉树的镜像定义:源二叉树     	    8    	   /  \    	  6   10    	 / \  / \    	5  7 9 11    	镜像二叉树    	    8    	   /  \    	  10   6    	 / \  / \    	11 9 7  5

class Solution:    # 返回镜像树的根节点    def Mirror(self, root):        if root == None:            return        if root.left == None and root.right == None:            return root        Temp = root.left        root.left = root.right        root.right = Temp        self.Mirror(root.left)        self.Mirror(root.right)

转载地址:http://lyfab.baihongyu.com/

你可能感兴趣的文章
mysql自动备份(Windows)
查看>>
FFmpeg安装(Centos6.5)
查看>>
PropertyUtils
查看>>
Spring+Websocket实现消息的推送
查看>>
https配置从tomcat迁移到Nginx
查看>>
spring-boot-hello-world
查看>>
分布式消息系统:Kafka
查看>>
java开发的微信公众号服务端生产环境中的两个大坑
查看>>
mysql-5.7.17-winx64免安装配置
查看>>
spring+mongodb的整合
查看>>
跨域请求
查看>>
从jvm的角度来看java的多线程
查看>>
Spring Boot 启用计划任务
查看>>
大学要毕业了
查看>>
华迪实训回来
查看>>
spring-boot-redis-cluster-demo
查看>>
spring-boot-ehcache-demo
查看>>
spring-boot-mybatis-demo
查看>>
spring-boot-druid-demo
查看>>
汇编实现斐波那契数列
查看>>