剑指offer——18.二叉树镜像
来源:互联网 发布:linux man pages 编辑:程序博客网 时间:2024/06/15 02:05
题目描述
操作给定的二叉树,将其变换为源二叉树的镜像
二叉树的镜像定义:源二叉树
8 / \ 6 10 / \ / \ 5 7 9 11 镜像二叉树 8 / \ 10 6 / \ / \ 11 9 7 5
代码
思路:先将根的左右节点互换,然后就是递归调用,对左右子树进行分别处理
function Mirror(root){ // write code here if(root==null) return null; //首先先将左右节点互换 var tmp = root.left; root.left=root.right; root.right=tmp; //递归 Mirror(root.left); Mirror(root.right);}
阅读全文
0 0
- 剑指offer——18.二叉树镜像
- 剑指offer——二叉树镜像
- 剑指offer-二叉树镜像
- 剑指offer 二叉树镜像
- 剑指offer:二叉树镜像
- 《剑指offer》二叉树镜像
- 【剑指 offer】(十九)—— 二叉树镜像
- 剑指offer——二叉树镜像、反转单词序列
- 剑指offer——重建二叉树
- 《剑指offer》——平衡二叉树
- 《剑指offer》——重建二叉树
- 剑指Offer——重建二叉树
- 剑指offer——平衡二叉树
- 剑指offer——重建二叉树
- 剑指Offer——二叉树
- 重建二叉树——剑指offer
- 剑指offer——重建二叉树
- 剑指offer——重建二叉树
- linux查看终端进程占用资源
- 动态规划之背包问题0.1
- FW(固件)库函数RCC_GetClocksFreq()
- vs2015字符格式转换代码
- 数据库优化手段
- 剑指offer——18.二叉树镜像
- Django上静态文件的配置方法
- [caioj]1489: 基于连通性状态压缩的动态规划问题:Formula 1
- pwnable之cmd2 & & shell 命令 绕过技巧
- HDU 6090-Rikka with Graph
- hdu1215
- php架构师之路
- JAVA中String类的intern()方法的作用
- 【数据结构】后缀表达式-->表达式树