Sept. 5, 2015

花时间把代码读明白, 比光看书强. 动手写代码, 改代码,  
兴趣是最好的老师. 多记几个例子, 增加情趣.

举个例子关于中序遍历,

4
/     \
2       6
/  \     / \
1   3   5   7 
easy way to travel is to remember the order of its position in the horizontal way 

现在, 要做Morris 的后序遍历, 有一个技巧, 是在我写完这个C#代码才发现的, 
9
/    \
5      8
/ \       \
1   4     7
/ \   /
2   3 6
就是从最左边开始, 遍历五次, 
1, 
2, 
3, 4, 5 
6, 
7, 8, 9, 
最后结果是 1 2 3 4 5 6 7 8 9 
加一个dummy node, with left child is the root node.  

Morris post order traversal

blogs to read:
http://www.cnblogs.com/AnnieKim/archive/2013/06/15/MorrisTraversal.html

C# implementation:
https://github.com/jianminchen/MorrisOrder/blob/master/MorrisPostOrder.cs

Morris order in order traversal

https://github.com/jianminchen/MorrisInOrderTraverse/blob/master/Program.cs

转载于:https://www.cnblogs.com/juliachenOnSoftware/p/4806102.html

Morris post order traversal algorithm相关推荐

  1. 107. Binary Tree Level Order Traversal II

    题目 Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from l ...

  2. 102. Binary Tree Level Order Traversal

    题目 Binary Tree Level Order Traversal 层次遍历二叉树 链接 Given a binary tree, return the level order traversa ...

  3. LeetCode: 107. Binary Tree Level Order Traversal II

    题目 Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from l ...

  4. LeetCode: 103. Binary Tree Zigzag Level Order Traversal

    题目 Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left ...

  5. LeetCode: 102. Binary Tree Level Order Traversal

    题目 Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to rig ...

  6. 【Binary Tree Level Order Traversal】cpp

    题目: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to ri ...

  7. 【leetcode】987. Vertical Order Traversal of a Binary Tree

    题目如下: Given a binary tree, return the vertical order traversal of its nodes values. For each node at ...

  8. Binary Tree Level Order Traversal II leetcode java

    题目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from ...

  9. Leetcode 102. Binary Tree Level Order Traversal(二叉树的层序遍历)

    Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...

最新文章

  1. idea编译项目 失败_在IntelliJ IDEA下使用Lombok时无法编译项目
  2. 仅靠一种普通的泡沫橡胶,这台机器人解决了“爬楼梯”的难题
  3. 错误学习:Java + OSGi
  4. NSOperation, NSOperationQueue 原理探析
  5. Centos/Red Hat6.8 安装、配置、启动Gitlab (内网环境)心得分享
  6. 我最喜欢的Bash骇客
  7. php自写代码加密,加密解密:教你加密自己写的VBS代码
  8. 前端系统化学习【JS篇】:(二)Javascript、变量和值的简述
  9. 简单使用linux感受,linux小白说说用linux的感受
  10. [Swift]LeetCode20. 有效的括号 | Valid Parentheses
  11. 论文笔记_S2D.22_2015-CVPR_利用深度特征回归和分层CRFs对单目图像进行深度和表面法线估计
  12. CPC是什么意思和CPM、CPV有什么不同?
  13. (含源码)麻雀搜索算法(SSA)的原理和matlab实现
  14. SaaS到底是什么,如何做?——这份我亲手整理的笔记您收好了!
  15. Android系统编译小总结
  16. ATF官方文档翻译(二):Authentication Framework Chain of Trust(身份验证框架和信任链)(1)
  17. ADODB.Recordset 错误 '800a0bb9' 参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
  18. android 系统的组成,简析Android 的GUI 系统组成
  19. 相干载波同步误差对相干解调的影响
  20. 4.MySQL的DQL查询数据

热门文章

  1. 网络推广运营过程中站长是否考虑过用户为什么愿意产生购买行为呢?
  2. 长沙计算机学校首问 长沙大计校区电话,长沙有哪些中专学校,长沙中专学校名单一览表...
  3. 水系影像分析_“天眼”助力 甘肃运用卫星影像精准研判灾情
  4. tensorflow sigmoid_cross_entropy_with_logits 函数解释
  5. wukong引擎源码分析之搜索——docid有序的数组里二分归并求交集,如果用跳表的话,在插入索引时会更快...
  6. lucene正向索引(续)——每次commit会形成一个新的段,段_1的域和词向量信息可能存在_0.fdt和_0.fdx”中...
  7. Javascript的this用法
  8. 萌新的九宫棋(C语言)
  9. Failed to read artifact descriptor for xxx:jar:版本号
  10. 九度OJ-1042-最长公共子序列(LCS)