Domanda di colloquio di Google

Print a BST level by level

Risposte di colloquio

Anonimo

5 set 2017

This is just a BFS of the tree

Anonimo

27 set 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)