Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:
其他好文 时间:
2015-04-23 23:19:15
阅读次数:
147
Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in th...
分类:
其他好文 时间:
2015-04-23 13:16:06
阅读次数:
124
对于一棵二叉树T,我们可以递归定义它的先序遍历,中序遍历,后序遍历:
??
1、先序遍历 ( PreOrder(T) = T的根节点 + PreOrder(T的左子树) + PreOrder(T的右子树) )
2、中序遍历 ( InOrder(T) = InOrder(T的左子树) + T的根节点 + InOrder(T的右子树) )
3、后...
分类:
其他好文 时间:
2015-04-23 11:02:56
阅读次数:
120
problem:
Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
Hide Tags
Tree Array Depth-first...
分类:
其他好文 时间:
2015-04-23 09:35:14
阅读次数:
157
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 solutio...
分类:
其他好文 时间:
2015-04-22 20:38:31
阅读次数:
133
problem:
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
Hide Tags
Tree Array Depth-first
...
分类:
其他好文 时间:
2015-04-22 11:49:15
阅读次数:
122
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:
其他好文 时间:
2015-04-18 07:35:36
阅读次数:
135
跟另一道题一样,不多说了public class Solution { public TreeNode buildTree(int[] inorder, int[] postorder) { // post就是pre的近似倒过来 if(inorder==null||...
分类:
其他好文 时间:
2015-04-18 06:26:50
阅读次数:
175
refhttp://www.cnblogs.com/springfor/p/3884034.html以下解释摘抄自 爱做饭的小莹子“题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:Yo...
分类:
其他好文 时间:
2015-04-18 06:23:56
阅读次数:
119
先采用比较简单的递归的方法来做#include#includeusing namespace std;struct TreeNode{ int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), ri...
分类:
其他好文 时间:
2015-04-17 21:47:10
阅读次数:
107