二叉樹的中序遍歷

從 qingwei personal wiki
於 2018年5月28日 (一) 14:36 由 Qingwei (對話 | 貢獻) 所做的修訂 (中序)
跳到: 導覽搜尋

中序

中序遍历首先遍历左子树,然后访问根结点,最后遍历右子树

相对于根来说,
* 中序指 根 中间次序访问
* 先序指 根 首先访问
* 后续指 根 最后访问

描述

leetcode

https://leetcode-cn.com/problems/binary-tree-inorder-traversal/description/
https://leetcode.com/problems/binary-tree-inorder-traversal/description/

問題

给定一个二叉树,返回它的中序 遍历。

示例:

输入: [1,null,2,3]
   1
    \
     2
    /
   3

输出: [1,3,2]