boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - tree traversal
相关主题
Construct Binary Tree from Preorder and Inorder Traversal算法复杂度?
再来bitch一下
出个题。reconstruct binary tree
请教一个binary search tree和heap的问题。
从tree的post order traversal和pre,能否build这个tree?
Amazon queston in cup
问道题,binary tree里有一个有indegree 2
non recursive binary tree traversal in O(n) time and O(1) space
这道FB题怎么做?
binary tree, sum of 2 nodes == given number
相关话题的讨论汇总
话题: tree话题: node话题: marker话题: traversal话题: root
进入JobHunting版参与讨论
1 (共1页)
r********t
发帖数: 395
1
http://careercup.com/question?id=405592
Q: Take a tree (binary or otherwise), write a method in any language that,
when given the root node, will print out the tree in level order. With a new
line after the end of every level.
Helper methods are ok, big O run time efficiency doesn't matter (though
obviously a quicker solution is better). Do not destroy original tree.
A:
1. queue.push(root)
2. queue.push(marker)
3. while queue not empty
node = queue.pop()
if(node == marker)
h**k
发帖数: 3368
2
这里marker就是一个标志,你可以用null。
1 (共1页)
进入JobHunting版参与讨论
相关主题
binary tree, sum of 2 nodes == given number
求LeetCode Binary Tree Level Order Traversal II解法
LeetCode 更新
check if a binary tree is a valid binary search tree
construct a binary tree from in-order and level-order trav
问一个G的面试题
Leetcode上Binary Tree Level Order Traversal II的疑问
啥叫encode/decode binary tree啊?
请教find number of duplicates in a binary search tree
被问到一道题: how to design a xml parser.
相关话题的讨论汇总
话题: tree话题: node话题: marker话题: traversal话题: root