Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
这道题与上一题类似, 要求根据二叉树的后序遍历序列和中序遍历序列构建二叉树。后序遍历序列的末尾是根节点,在中...
分类:
其他好文 时间:
2015-02-14 13:47:49
阅读次数:
216
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 example:
Given binary tree {3,9,20,#...
分类:
其他好文 时间:
2015-02-13 21:12:18
阅读次数:
136
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,9,20,#,#,15,7},
3...
分类:
其他好文 时间:
2015-02-13 20:01:56
阅读次数:
136
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 alternate between).
For example:
Giv...
分类:
其他好文 时间:
2015-02-13 19:59:21
阅读次数:
198
Given a binary tree, return the inorder traversal of its nodes’ values.
For example:
Given binary tree {1,#,2,3},
1
\
2
/
3...
分类:
其他好文 时间:
2015-02-13 18:40:15
阅读次数:
189
原因:
之所以写这个主要是因为我自认为自己对自定义View已经了如指掌,但是后来才发现自己犯了很多低级错误。
详解:
按照源码的注释,View的绘制过程是这样子的:
/*
* Draw traversal performs several drawing steps which must be executed
* in the ...
分类:
移动开发 时间:
2015-02-12 16:22:19
阅读次数:
180
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 ...
分类:
其他好文 时间:
2015-02-11 16:23:02
阅读次数:
144
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...
分类:
其他好文 时间:
2015-02-11 09:21:46
阅读次数:
137
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...
分类:
其他好文 时间:
2015-02-10 22:56:46
阅读次数:
204
广度遍历二叉树,且要分别记录每一层的数据,方法有二。
1.迭代法
设置两个队列,其中一个队列用于存放上一层的节点,另一个队列用于存放下一层的节点。轮番使用。
class Solution {
public:
vector > levelOrder(TreeNode *root) {
queue q1,q2;
vector> result;
if(!root) return...
分类:
其他好文 时间:
2015-02-09 16:03:19
阅读次数:
177