码迷,mamicode.com
首页 >  
搜索关键字:traversal    ( 1649个结果
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. For example, ...
分类:其他好文   时间:2018-08-19 13:57:40    阅读次数:107
二叉树深度优先遍历和广度优先遍历
对于一颗二叉树,深度优先搜索(Depth First Search)是沿着树的深度遍历树的节点,尽可能深的搜索树的分支。以上面二叉树为例,深度优先搜索的顺序 为:ABDECFG。怎么实现这个顺序呢 ?深度优先搜索二叉树是先访问根结点,然后遍历左子树接着是遍历右子树,因此我们可以利用堆栈的先进后出的特 ...
分类:其他好文   时间:2018-08-18 00:58:31    阅读次数:195
LeetCode 145. 二叉树的后序遍历(Binary Tree Postorder Traversal)
题目描述 给定一个二叉树,返回它的 后序 遍历。 示例: 输入: [1,null,2,3] 1 \ 2 / 3 输出: [3,2,1] 进阶: 递归算法很简单,你可以通过迭代算法完成吗? 给定一个二叉树,返回它的 后序 遍历。 示例: 进阶: 递归算法很简单,你可以通过迭代算法完成吗? 解题思路 后 ...
分类:其他好文   时间:2018-08-17 17:49:08    阅读次数:172
314. Binary Tree Vertical Order Traversal
314. Binary Tree Vertical Order Traversal /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode ri... ...
分类:其他好文   时间:2018-08-17 00:37:02    阅读次数:132
230. Kth Smallest Element in a BST
230. Kth Smallest Element in a BST // dfs inroder traversal recursively , record the first k nodes , return the kth node Solution { List result = new ... ...
分类:其他好文   时间:2018-08-09 19:28:13    阅读次数:137
in order traversal
in order traversal /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) ... ...
分类:其他好文   时间:2018-08-09 18:32:47    阅读次数:170
【leetcode】145. Binary Tree Postorder Traversal
题目如下: 解题思路:凑数题+3,搞不懂为什么本题的难度是Hard,而【leetcode】590. N-ary Tree Postorder Traversal是Medium。 代码如下: ...
分类:其他好文   时间:2018-08-01 12:02:10    阅读次数:159
【leetcode】590. N-ary Tree Postorder Traversal
题目如下: 解题思路:凑数题+2,做完先序做后序。凑数博+2。 代码如下: ...
分类:其他好文   时间:2018-07-31 22:01:30    阅读次数:178
【leetcode】589. N-ary Tree Preorder Traversal
题目如下: 解题思路:凑数题+1,话说我这个也是凑数博? 代码如下: ...
分类:其他好文   时间:2018-07-31 21:42:07    阅读次数:245
[LeetCode] 590. N-ary Tree Postorder Traversal_Easy
Given an n-ary tree, return the postorder traversal of its nodes' values. For example, given a 3-ary tree: Return its postorder traversal as: [5,6,3,2 ...
分类:其他好文   时间:2018-07-22 11:29:49    阅读次数:172
1649条   上一页 1 ... 30 31 32 33 34 ... 165 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!