码迷,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}, return[1,3,2]. 题目的意思是进行树的中序遍历。很明显在 ...
分类:其他好文   时间:2017-12-12 21:41:09    阅读次数:96
Python实现二叉树的非递归中序遍历
思路: 1. 使用一个栈保存结点(列表实现); 2. 如果结点存在,入栈,然后将当前指针指向左子树,直到为空; 3. 当前结点不存在,则出栈栈顶元素,并把当前指针指向栈顶元素的右子树; 4. 栈不为空,循环2、3部。 代码如下,解决了leetcode94. Binary Tree Inorder T ...
分类:编程语言   时间:2017-11-15 23:41:54    阅读次数:274
Leetcode:Construct Binary Tree from Preorder and Inorder Traversal
题目大意:分别按先序和中序遍历同一个n结点二叉树,得到两个结点数组P和I。要求利用这些结点数组还原二叉树。 这道题考验对二叉树的理解。先说明一些基础的知识: 先序遍历表示当访问一个结点时,先访问结点值,再访问结点的左孩子,最后访问结点的右孩子。 中序遍历表示当访问一个结点时,先访问结点的左孩子,再访 ...
分类:其他好文   时间:2017-11-10 00:37:07    阅读次数:198
lintcode448- Inorder Successor in Binary Search Tree- medium
Given a binary search tree (See Definition) and a node in it, find the in-order successor of that node in the BST. If the given node has no in-order s ...
分类:其他好文   时间:2017-10-17 15:05:49    阅读次数:185
105. 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. 给定一个二叉树的先序遍历和 ...
分类:其他好文   时间:2017-10-16 16:41:54    阅读次数:137
105. 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. 方法一:迭代 方法二:递归 ...
分类:其他好文   时间:2017-10-10 19:20:19    阅读次数:147
1020. Tree Traversals (25)
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou ...
分类:其他好文   时间:2017-10-09 13:11:11    阅读次数:153
LeetCode:二叉树的非递归中序遍历
第一次动手写二叉树的,有点小激动,64行的if花了点时间,上传leetcode一次点亮~~~ 1 /* inorder traversal binary tree */ 2 #include 3 #include 4 5 6 struct TreeNode { 7 int val; 8 struct... ...
分类:其他好文   时间:2017-10-01 14:25:12    阅读次数:159
106. Construct Binary Tree from Inorder and Postorder Traversal
public class Solution { public TreeNode buildTree(int[] inorder, int[] postorder) { return buildTree(inorder, 0, inorder.length-1, postorder, 0, posto... ...
分类:其他好文   时间:2017-09-29 13:22:01    阅读次数:155
105. Construct Binary Tree from Preorder and Inorder Traversal
public class Solution { public TreeNode buildTree(int[] preorder, int[] inorder) { return buildTree(preorder, 0, preorder.length-1, inorder, 0, inorde... ...
分类:其他好文   时间:2017-09-29 12:42:31    阅读次数:182
706条   上一页 1 ... 14 15 16 17 18 ... 71 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!