from collections import deque
def levelOrderTraversal(root):
q = deque()
q.append(root)
while q:
curr = q.popleft()
print(curr.data, end=' ')
if curr.left:
q.append(curr.left)
if curr.right:
q.append(curr.right)