As the note in the problem statement, this problem has a straight-forward O(n)-space solution, which is to generate the inorder traversal results of t...
分类:
其他好文 时间:
2015-07-16 00:41:35
阅读次数:
115
Given a binary tree, return the inorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3},
return [1,3,2].Note: Recursive solution is trivial, could you do it iteratively?二叉树的...
分类:
其他好文 时间:
2015-07-14 11:42:35
阅读次数:
94
https://leetcode.com/problems/binary-tree-inorder-traversal/递归中序遍历 1 /** 2 * Definition for a binary tree node. 3 * struct TreeNode { 4 * int v...
分类:
其他好文 时间:
2015-07-10 18:21:58
阅读次数:
122
Binary Tree Preorder Traversal 题目链接 题目要求: Given a binary tree, return thepreordertraversal of its nodes' values. For example: Given binary tree{1...
分类:
其他好文 时间:
2015-07-09 13:04:42
阅读次数:
91
题目:
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].
解题:
中序遍历一颗二叉树,如...
分类:
编程语言 时间:
2015-07-08 13:07:37
阅读次数:
141
既然已经分别找到了左、右子树的前序遍历序列和中序遍历序列,我们可用同样的方法分别去构建左右子树。所以,接下来的事情可用递归的方法去完成。
递归代码如下:
BinaryTreeNode* Construct(int* preorder, int *inorder, int length)
{
if (preorder == NULL || inorder == NULL || length...
分类:
其他好文 时间:
2015-07-02 22:36:19
阅读次数:
256
LeetCode_Construct Binary Tree from Preorder and Inorder Traversal 解题思路...
分类:
其他好文 时间:
2015-06-29 20:27:59
阅读次数:
76
LeetCode_Construct Binary Tree from Inorder and Postorder Traversal 解题思路...
分类:
其他好文 时间:
2015-06-29 20:26:47
阅读次数:
82
Given preorder and inorder (Inorder and Postorder) traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
前序和后序的特点是根结点要么在最前面、要么在最后...
分类:
其他好文 时间:
2015-06-22 09:56:49
阅读次数:
138
Description:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.Co...
分类:
其他好文 时间:
2015-06-20 15:39:21
阅读次数:
108