Given a binary tree, return the postorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [3,2,1].
Note: Recursive solut...
分类:
其他好文 时间:
2014-09-19 17:42:05
阅读次数:
158
Given a binary tree, return the preorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,2,3].
Note: Recursive soluti...
分类:
其他好文 时间:
2014-09-19 17:40:15
阅读次数:
177
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and ...
分类:
其他好文 时间:
2014-09-16 15:32:10
阅读次数:
243
Given inorder and postorder traversal of a tree, construct the binary tree.与Construct Binary Tree from Inorder and Preorder Traversal问题非常类似,唯一区别在于这一次确...
分类:
其他好文 时间:
2014-09-16 12:09:50
阅读次数:
212
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.难度:95,参考了网上的思路。...
分类:
其他好文 时间:
2014-09-16 12:09:00
阅读次数:
174
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For e...
分类:
其他好文 时间:
2014-09-15 14:13:38
阅读次数:
153
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,...
分类:
其他好文 时间:
2014-09-15 14:07:38
阅读次数:
175
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2]....
分类:
其他好文 时间:
2014-09-15 09:54:08
阅读次数:
135
Construct Binary Tree from Preorder and Inorder Traversal 结题报告
从前序遍历和中序遍历的结果重建一颗二叉树。
解题思路,随便写一个二叉树,然后写出前序和中序遍历的结果会发现特点。
二叉树的首节点必然是前序遍历的第一个节点,以这个节点在中序遍历的结果中作为划分,这个节点左侧的是左子树的节点,右侧是右子树节点。
例如,一个二叉...
分类:
其他好文 时间:
2014-09-14 20:48:47
阅读次数:
176
loop、iterate、traversal和recursion这几个词是计算机技术书中经常会出现的几个词汇。众所周知,这几个词分别翻译为:循环、迭代、遍历和递归。乍一看,这几个词好像都与重复(repeat)有关,但有的又好像不完全是重复的意思。那么这几个词到底各是什么含义,有什么区别和联系呢?下面...
分类:
其他好文 时间:
2014-09-13 21:22:05
阅读次数:
538