Given a binary tree, return the preorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,2,3].
Note: Recursive soluti...
分类:
其他好文 时间:
2014-12-19 12:14:35
阅读次数:
118
Binary Tree Postorder Traversal Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ ...
分类:
其他好文 时间:
2014-12-18 23:31:30
阅读次数:
236
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,#,#,15,7},
...
分类:
其他好文 时间:
2014-12-17 09:50:15
阅读次数:
169
UVA - 572
Oil Deposits
Time Limit: 3000MS
Memory Limit: Unknown
64bit IO Format: %lld & %llu
Submit Status
Description
Oil Deposits
T...
分类:
其他好文 时间:
2014-12-16 22:47:56
阅读次数:
629
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
For example:
Given binary tree {3,9,20,#,#,15,7},
3
/ 9 20
/ ...
分类:
其他好文 时间:
2014-12-16 22:46:46
阅读次数:
223
本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/41964067
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)....
分类:
其他好文 时间:
2014-12-16 21:07:59
阅读次数:
207
原题链接:https://oj.leetcode.com/problems/binary-tree-inorder-traversal/
题目大意:中序遍历二叉树
解题思路:中序遍历二叉树,中序遍历二叉树的左子树,访问根结点,中序遍历二叉树的右子树。非递归实现时,用一个栈模拟遍历过程即可。因为需要先遍历左子树,所以每个结点先入栈,出栈时访问。
vector inorderTraversal(...
分类:
其他好文 时间:
2014-12-16 11:53:51
阅读次数:
172
原题链接:https://oj.leetcode.com/problems/binary-tree-postorder-traversal/
题目大意:后序遍历二叉树
解题思路:后序遍历二叉树的步骤:后序遍历二叉树的左子树,后序遍历二叉树的右子树,访问根结点。非递归实现时,用一个栈模拟遍历过程。由于访问完左子树后访问右子树,栈中元素要起到转向访问其右子树的作用,但是不能像先序和中序遍历那样出栈...
分类:
其他好文 时间:
2014-12-16 11:53:41
阅读次数:
183
Binary Tree *-order traversal by recursion is trivial. But their iteration version deserves a look:Pre-Orderclass Solution { vector ret;public: ...
分类:
其他好文 时间:
2014-12-16 07:39:36
阅读次数:
206
Binary Tree Level Order TraversalGiven a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).Fo...
分类:
其他好文 时间:
2014-12-15 18:59:13
阅读次数:
148