后序遍历的遍历中,某一个节点要被输出,在两种情况下:当前节点的左右孩子为空;当前节点的左右孩子已经被访问。

第一种情况非常容易判断

第二种情况需要记录访问过的节点,显然当前节点如果有孩子,则对它的访问会紧跟在它的孩子节点之后,无论是左右。

所以只需记录每次访问的节点,就Ok!

[1]http://www.cnblogs.com/changchengxiao/p/3416402.html

转载于:https://www.cnblogs.com/deepblueme/p/4675482.html

[Leetcode] Binary Tree PosterOrder Travel相关推荐

  1. [LeetCode] Binary Tree Level Order Traversal 二叉树层次遍历(DFS | BFS)

    目录: 1.Binary Tree Level Order Traversal - 二叉树层次遍历 BFS 2.Binary Tree Level Order Traversal II - 二叉树层次 ...

  2. Leetcode | Binary Tree Maximum Path Sum

    Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. ...

  3. LeetCode Binary Tree Right Side View(搜索)

    问题:给出一个二叉树,要求输出右视图 思路:因为要求输出右视图.可以考虑使用深度优先搜索或者 广度优先搜索. 使用深度优先搜索时,以非递归形式,将左右子树入栈,同时使用哈希表记录深度与对应右视图的值. ...

  4. LeetCode Binary Tree Preorder Traversal(二叉树的前序遍历)

    问题:给出一个二叉树,输出前序遍历 思路: 自顶向下遍历过程中,将当前结点的值加入到list中,然后处理左.右子树 具体代码参考: https://github.com/wuli2496/OJ/tre ...

  5. [LeetCode] Binary Tree Postorder Traversal 二叉树的后序遍历

    Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary ...

  6. [LeetCode] Binary Tree Postorder题解

    Binary Tree Postorder Given a binary tree, return the postorder traversal of its nodes' values. For ...

  7. [Leetcode] Binary Tree Maximum Path Sum

    这是LeetCode上的一道题目,需要求二叉树中两点路径的最大和.原题是 https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/ ...

  8. [leetcode] Binary Tree Preorder Traversal

    Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary t ...

  9. LeetCode Binary Tree Inorder Traversal

    Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tr ...

最新文章

  1. 织梦DeDE调用文章第一张图片的方法
  2. 对一些架构设计原则的反思
  3. canvas 绘制跟随鼠标移动的线条
  4. Web APP开发技巧总结(转)
  5. Spring主要用到两种设计模式
  6. Struts里面的配置笔记
  7. 用异或的性质实现简单加密解密
  8. Number.isInteger()
  9. 网易2017春招笔试真题编程题集合
  10. 学python要什么基础-学Python首先要学什么?
  11. html mysql 数据列表_html的列表加载数据库
  12. axure 鼠标样式_Axure教程:简单开关按钮的实现
  13. 组态王网页服务器,组态王服务器 客户端
  14. 【面经】Thoughtworks软开实习
  15. ad转换中断方式C语言程序,STC12C2052AD AD转换C程序 +PWM输出功能实现
  16. U盘所有文件(夹)变成.exe文件的解决方法
  17. 下一步工作应该怎样开展
  18. Mac升级python3版本
  19. 旅行社旅游APP开发维护经验
  20. 物理五大信道浅聊PRACH、PUCCH、PUSCH、PDCCH、PDSCH

热门文章

  1. 两难!到底用 Spring BeanUtils 还是 Apache BeanUtils?
  2. RocketMQ削峰
  3. 从七个方面,面试大厂高级工程师
  4. Java 的转义字符
  5. python opencv resize函数_Python OpenCV中的resize()函数的使用
  6. 塞内加尔将于5月启用全国首个大型数据中心
  7. 浅谈数据中心IT机房的空气调节(上篇)-气流遏制
  8. 提高数据中心空间使用率,助力数字新基建
  9. 浅谈巴拿马电源的谐波消除原理
  10. 暖通空调系统计量表选型与应用