码迷,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]. /** * Definition for b...
分类:其他好文   时间:2014-10-08 10:45:45    阅读次数:106
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. /** * Definition for binary tree * struct TreeNode { ...
分类:其他好文   时间:2014-10-06 14:46:30    阅读次数:202
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-10-06 14:45:50    阅读次数:178
[Leetcode][JAVA] Binary Tree Preorder Traversal, Binary Tree Inorder Traversal, Binary Tree Postorder Traversal
Binary Tree PreOrder Traversal:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ ...
分类:编程语言   时间:2014-10-04 02:51:25    阅读次数:285
Construct Binary Tree from Preorder and Inorder Traversal<leetcode>
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.题意:知道二叉树的前序遍历和中...
分类:其他好文   时间:2014-09-29 23:47:51    阅读次数:265
Binary Tree Inorder Traversal [leetcode] 非递归的三种解法
第一种方法是Morris Traversal 是O(n)时间复杂度,且不需要额外空间的方法。缺点是需要修改树。 通过将叶子节点的right指向其中序后继。 代码如下 vector inorderTraversal(TreeNode *root) { vector res; TreeNode * cur = root; TreeNode...
分类:其他好文   时间:2014-09-27 22:46:50    阅读次数:195
Leetcode_num9_Binary Tree Inorder Traversal
同num8一样,此题考查的是二叉树的中序遍历,即先左子树再节点再右子树、 使用迭代法时,采用将节点和左子树均压入栈的方法,当左子树为NULL时,将top节点弹出,并存入结果列表,将next指针指向该节点的右节点 代码如下: /** * Definition for binary tree * struct TreeNode { * int val; * Tre...
分类:其他好文   时间:2014-09-24 20:04:07    阅读次数:177
编程算法 - 中序遍历 递归/迭代 代码(C)
中序遍历 递归/迭代 代码(C)本文地址: http://blog.csdn.net/caroline_wendy中序遍历(InOrder)作为二叉搜索树的排序方式, 有着重要的作用.递归和迭代的方法都需要掌握, 迭代主要使用了栈(stack)进行输入输出.代码:/* * main.cpp * * Created on: 2014.9.18 * Author: Spike *...
分类:其他好文   时间:2014-09-22 11:48:28    阅读次数:186
LeetCode Binary Tree Inorder Traversal
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:其他好文   时间:2014-09-20 14:19:48    阅读次数:204
Leetcode: Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.与Construct Binary Tree from Inorder and Preorder Traversal问题非常类似,唯一区别在于这一次确...
分类:其他好文   时间:2014-09-16 12:09:50    阅读次数:212
706条   上一页 1 ... 60 61 62 63 64 ... 71 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!