Print a BST level by level
Utilisateur anonyme
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)