1from collections import deque
2def levelOrderTraversal(root):
3 q = deque()
4 q.append(root)
5 while q:
6 curr = q.popleft()
7 print(curr.data, end=' ')
8 if curr.left:
9 q.append(curr.left)
10 if curr.right:
11 q.append(curr.right)