📅  最后修改于: 2022-03-11 14:47:15.901000             🧑  作者: Mango
# tree level-by-level traversal. O(n) time/space
def breadthFirstSearch(root):
q = [root]
while q:
current = q.pop(0)
print(current)
if current.left is not None: q.append(current.left)
if current.right is not None: q.append(current.right)