一、前序 1 public List preOrder(Node root){ 2 List res = new LinkedList(); 3 Stack stack = new Stack(); 4 stack.push(root); 5 while(root!=...
分类:
其他好文 时间:
2015-08-15 01:28:01
阅读次数:
116
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]...
分类:
其他好文 时间:
2015-08-12 13:09:34
阅读次数:
123
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 the tre...
分类:
其他好文 时间:
2015-08-11 18:58:28
阅读次数:
145
【106-Construct Binary Tree from Inorder and Postorder Traversal(通过中序和后序遍历构造二叉树II)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given inorder and postorder traversal of a tree, construct the binary tree.
No...
分类:
编程语言 时间:
2015-08-09 07:14:18
阅读次数:
192
【106-Construct Binary Tree from Preorder and Inorder Traversal(通过前序和中序遍历构造二叉树)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given preorder and inorder traversal of a tree, construct the binary tree.
Note:...
分类:
编程语言 时间:
2015-08-09 07:13:59
阅读次数:
234
1020. Tree Traversals (25)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequenc...
分类:
其他好文 时间:
2015-08-07 01:49:17
阅读次数:
113
??
#include
#include
#include
#include
using namespace std;
typedef struct Node
{
Node * lchild,*rchild;
char value;
} Tree;
void ReBuild(char *PreOrder,char *InOrder,int TreeLen,Tree** r...
分类:
其他好文 时间:
2015-08-06 20:34:44
阅读次数:
127
Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return...
分类:
其他好文 时间:
2015-08-06 15:08:56
阅读次数:
86
【094-Binary Tree Inorder Traversal(二叉树中序遍历)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given a binary tree, return the inorder traversal of its nodes’ values.
题目大意 对一棵二叉树进行中序遍历。
解题思路 解法一:递归实现,解法二:迭代实现。...
分类:
编程语言 时间:
2015-08-06 08:18:21
阅读次数:
305
105 Construct Binary Tree from Preorder and Inorder Traversal这道题纯递归class Solution: # @param {integer[]} preorder # @param {integer[]} inorder ...
分类:
其他好文 时间:
2015-08-06 07:04:10
阅读次数:
120