码迷,mamicode.com
首页 >  
搜索关键字:preorder traversal    ( 1851个结果
leetcode -- Binary Tree Postorder Traversal
历史不容假设[问题描述]Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3retu...
分类:其他好文   时间:2014-08-14 19:30:29    阅读次数:191
Binary Tree Preorder Traversal
#define NULL 0class Solution {public: vector preorderTraversal(TreeNode *root) { stack s; vector v1; if(root!=NULL) s.p...
分类:其他好文   时间:2014-08-14 13:35:48    阅读次数:210
leetcode 刷题之路 78 Binary Tree Postorder Traversal
非递归方式实现二叉树的后序遍历。...
分类:其他好文   时间:2014-08-12 17:24:24    阅读次数:173
leetcode 刷题之路 79 Binary Tree Preorder Traversal
非递归实现树的前序遍历...
分类:其他好文   时间:2014-08-12 17:22:54    阅读次数:184
Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3]...
分类:其他好文   时间:2014-08-11 11:53:42    阅读次数:185
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 \ 2 / 3return [3,2,1...
分类:其他好文   时间:2014-08-11 11:45:02    阅读次数:251
Given a tree, find the node with the minimum sum of distances to other nodes
O(n) complexity, have a traversal for the tree. Get the information of all children, then traverse the tree again.  #include #include #include #include using namespace std; class Node { pub...
分类:其他好文   时间:2014-08-10 13:00:30    阅读次数:238
Binary Tree Postorder Traversal && Binary Tree Preorder Traversal
注:后序遍历是较麻烦的一个,不可大意。关键两点: 1.要走到 p->left | p->right ==0, 2.每次出栈出两个结点。
分类:其他好文   时间:2014-08-10 01:45:39    阅读次数:286
leetcode 刷题之路 63 Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). zigzag层序遍历树 For example: Given binary...
分类:其他好文   时间:2014-08-09 23:19:59    阅读次数:363
leetcode 刷题之路 64 Construct Binary Tree from Inorder and Postorder Traversal
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-08-09 23:15:09    阅读次数:312
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!