Pergunta de entrevista da empresa Meta

Print tree level by level, with a new line for each level

Respostas da entrevista

Sigiloso

28 de nov. de 2012

breadth depth search is the most optimal here, but keeping track of when you're on a new level is quite difficult if the tree is not perfectly balanced.

Sigiloso

4 de dez. de 2012

In python, this would work: http://pastie.org/5478481 It's similar to a BFS, but with the extras to keep track of the level.