码迷,mamicode.com
首页 >  
搜索关键字:traversal    ( 1649个结果
[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.方法一:最先想到的就是递归,注...
分类:其他好文   时间:2014-07-10 09:58:40    阅读次数:224
[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.方法:在inorder中寻找...
分类:其他好文   时间:2014-07-07 23:18:53    阅读次数:283
[Leetcode][Tree][Binary Tree Preorder Traversal]
二叉树的前序遍历:root点先被访问,然后是left和right子节点。迭代的版本也相对好写。1、递归版本:时间复杂度O(N),空间复杂度O(N) 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int va...
分类:其他好文   时间:2014-07-07 20:35:24    阅读次数:158
[Leetcode][Tree][Binary Tree Inorder Traversal]
二叉树的中序遍历1、递归版本/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) :...
分类:其他好文   时间:2014-07-07 20:00:20    阅读次数:161
[Leetcode][Tree][Binary Tree Postorder Traversal]
二叉树的后续遍历1、递归版本/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) :...
分类:其他好文   时间:2014-06-30 14:17:28    阅读次数:306
leetcode 题解:Binary Tree Preorder Traversal (二叉树的先序遍历)
题目:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3]....
分类:其他好文   时间:2014-06-26 16:03:52    阅读次数:296
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].N...
分类:其他好文   时间:2014-06-26 16:02:42    阅读次数:172
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 / 3return[3,2,1]...
分类:其他好文   时间:2014-06-26 15:59:16    阅读次数:207
LeetCode——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 / 3 return [3,2,1]. Note: Recursive solut...
分类:其他好文   时间:2014-06-22 20:58:01    阅读次数:157
LeetCode——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 / 3 return [1,2,3]. Note: Recursive soluti...
分类:其他好文   时间:2014-06-22 16:37:51    阅读次数:168
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!