Pregunta de entrevista de Meta

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

Respuestas de entrevistas

Anónimo

28 nov 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.

Anónimo

4 dic 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.