码迷,mamicode.com
首页 >  
搜索关键字:traversal    ( 1649个结果
【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 solution is trivial, could you do it iteratively?...
分类:其他好文   时间:2014-11-08 13:41:21    阅读次数:155
leetcode:Binary Tree Level Order Traversal
该题做法同 Binary Tree Level Order Traversal II,不过是结果没有反转就是了,详细见 http://blog.csdn.net/zzucsliang/article/details/40841527...
分类:其他好文   时间:2014-11-07 20:52:02    阅读次数:139
Leetcode:Binary_Tree_Level_Order_Traversal_II
给定一个二叉树,由自底向上的层次顺序遍历返回其节点的值。...
分类:其他好文   时间:2014-11-06 00:44:14    阅读次数:209
Serialize a Binary Tree or a General Tree
For a binary tree, preorder traversal may be enough.   For example,      _30_    /   \      10    20  /     /  50    45  35 The result is  30 10 50 # # # 20 45 # # 35 # # Using a queue ...
分类:其他好文   时间:2014-11-03 16:28:42    阅读次数:242
leetcode Binary Tree Level Order Traversal I II
Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
分类:其他好文   时间:2014-11-02 07:06:13    阅读次数:195
[Leetcode] Binary Tree Level Order Traversal II
Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa...
分类:其他好文   时间:2014-11-02 07:04:55    阅读次数:202
树的序列化
1. BST只保存preorder或者postorder就够了,递归有O(n^2)和O(n)算法。非递归有利用栈的O(n)算法。2. Complete binary treelevel traversal就行了。3. Full binary tree用一个bit来保存该结点是internal nod...
分类:其他好文   时间:2014-10-31 21:53:15    阅读次数:253
[leetcode]Binary Tree Level Order Traversal II
问题描述: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For example: Given binary tree {3,9,20,#,#,...
分类:其他好文   时间:2014-10-27 21:21:00    阅读次数:190
[leetcode]Binary Tree Level Order Traversal
问题描述: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#,#,15,7}, 3 / 9 ...
分类:其他好文   时间:2014-10-27 21:19:34    阅读次数:236
Binary Tree Preorder Traversal
递归实现(python):# Definition for a binary tree nodeclass TreeNode: def __init__(self, x): self.val = x self.left = None self...
分类:其他好文   时间:2014-10-27 17:21:37    阅读次数:125
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!