走啊,老大,跟我回家过年吧# bagua - 娱乐八卦
r*t
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)
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)