问题描述:
Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
基本思路:
与前一篇《Construct Binary Tree from Preord...
分类:
其他好文 时间:
2014-11-23 11:51:28
阅读次数:
172
问题描述:
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
基本思路:
找到规律,递归的解决左子树和右子树。
代码:
/**
* D...
分类:
其他好文 时间:
2014-11-23 10:32:58
阅读次数:
190
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...
分类:
其他好文 时间:
2014-11-20 17:05:34
阅读次数:
205
Binary Tree Inorder TraversalGiven a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ...
分类:
其他好文 时间:
2014-11-17 22:36:09
阅读次数:
271
【题目】
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: Recursi...
分类:
其他好文 时间:
2014-11-17 17:52:41
阅读次数:
191
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.后序遍历的最后一个元素就是根...
分类:
其他好文 时间:
2014-11-11 00:40:07
阅读次数:
189
火车进站,模拟一个栈的操作,额外的栈操作,查看能否依照规定顺序出栈。数据量非常少,故此题目非常easyAC。直接使用数组模拟就好。#include const int MAX_N = 10;char inOrder[MAX_N], outOrder[MAX_N], stk[MAX_N];bool r...
分类:
其他好文 时间:
2014-11-10 13:33:59
阅读次数:
256
Given inorder and level-order traversals of a Binary Tree, construct the Binary Tree. Following is an example to illustrate the problem.BinaryTreeInpu...
分类:
其他好文 时间:
2014-11-09 20:41:07
阅读次数:
196
Given a BST, transform it into greater sum tree where each node contains sum of all nodes greater than that node.自己想的复杂了,其实就是一个反向的inorder。新的值就是前面所有元素的...
分类:
其他好文 时间:
2014-11-09 15:07:49
阅读次数:
186