标签:des style blog color java strong io for
题目:
Given a binary tree, return the inorder traversal of its nodes‘ values.
For example:
Given binary tree {1,#,2,3}
,
1 2 / 3
return [1,3,2]
.
Note: Recursive solution is trivial, could you do it iteratively?
题解:
中序遍历:递归左 处理当前 递归右。
画图的话就是,之前离散老师教的,从root开始沿着子树画线,遍历完全树,每一个被画线画到2次的就表示遍历到了,依次写出就行了。
递归代码如下:
非递归代码如下:
Binary Tree Inorder Traversal leetcode java,布布扣,bubuko.com
Binary Tree Inorder Traversal leetcode java
标签:des style blog color java strong io for
原文地址:http://www.cnblogs.com/springfor/p/3877179.html