Pregunta de entrevista de Google

Print a BST level by level

Respuestas de entrevistas

Anónimo

5 sept 2017

This is just a BFS of the tree

Anónimo

27 sept 2017

This is known as a Level Order Traversal, more or less just a typical BFS. Here's a Python implementation: def level_order(root): q = [root] while q: cur = q.pop(0) print(cur.data) if (cur.left): q.append(cur.left) if (cur.right): q.append(cur.right)