码迷,mamicode.com
首页 >  
搜索关键字:inorder    ( 706个结果
LeetCode——Binary Tree Inorder Traversal
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-08-16 11:15:00    阅读次数:227
HDU 1022 Train Problem I 模拟栈题解
火车进站,模拟一个栈的操作,额外的栈操作,查看是否能按照规定顺序出栈。 数据量很少,故此题目很容易AC。 直接使用数组模拟就好。 #include const int MAX_N = 10; char inOrder[MAX_N], outOrder[MAX_N], stk[MAX_N]; bool rs[MA...
分类:其他好文   时间:2014-08-12 03:27:23    阅读次数:232
先序+中序和中序+后序建树
思路:先序的第一个元素和后序的最后一个元素是当前子树的根,然后遍历中序序列,找到左右子树的分界线,递归建左子树和右子树。 class Solution { public: /*由于是oj,这里假设给的序列是合法的,正常情况是需要判断不合法情况的 */ TreeNode *buildTree(vector &inorder, vector &postorder,int instar...
分类:其他好文   时间:2014-08-11 21:37:42    阅读次数:504
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
[LeetCode] Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree./** * Definiti...
分类:其他好文   时间:2014-08-05 00:01:38    阅读次数:271
[LeetCode] 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.class Solutio...
分类:其他好文   时间:2014-08-04 23:57:18    阅读次数:476
Binary Tree Inorder Traversal
问题:二叉树中序遍历递归实现/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) :...
分类:其他好文   时间:2014-08-02 12:40:33    阅读次数:162
【LeetCode】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. /** * Definition for binary tree * struct TreeNode {...
分类:其他好文   时间:2014-08-01 19:53:32    阅读次数:222
Construct Binary Tree from Inorder and Postorder Traversal Traversal leetcode java
题目:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.题解:这道题跟pre....
分类:编程语言   时间:2014-08-01 06:56:51    阅读次数:185
Construct Binary Tree from Preorder and Inorder Traversal leetcode java
题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.题解: 1 ...
分类:编程语言   时间:2014-08-01 06:56:41    阅读次数:228
706条   上一页 1 ... 63 64 65 66 67 ... 71 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!