Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.C++实现代码:#inclu...
分类:
其他好文 时间:
2014-11-24 11:47:33
阅读次数:
281
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.提交成功的代码:C++实现:#...
分类:
其他好文 时间:
2014-11-24 11:26:30
阅读次数:
251
TreeNode a;while (a.hasNext()) visit(a.next());}" 问:给TreeNode写Iterator,使得以上代码可以in order traversalclass TreeNode{TreeNode *root;public: bool hasNext...
分类:
其他好文 时间:
2014-11-24 07:35:51
阅读次数:
143
二叉树的后序遍历用标记右子树vector的方法vector postorderTraversal(TreeNode *root) { vector ans; vector stack; vector isRight; stack.push_b...
分类:
其他好文 时间:
2014-11-23 15:39:43
阅读次数:
160
问题描述:
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
https://oj.leetcode.com/problems/binary-tree-level-order-traversal/ Given a binary tree, return the level order traversal of its nodes' values. (ie, f...
分类:
其他好文 时间:
2014-11-19 08:33:46
阅读次数:
179
题目描述:
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,...
分类:
其他好文 时间:
2014-11-18 10:25:11
阅读次数:
145
【题目】
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