import queue
class TreeNode:
def init(self,val=None,left=None,right=None):
self.val = val
self.left = left
self.right = right
def settag(self,tag=None):
self.tag = tag
def visit(treenode):
print(str(treenode.val),end=' ')
def levelOrder(root):
deque = queue.Queue()
if(root is not None):
deque.put(root)
while(not deque.empty()):
treenode = deque.get()
visit(treenode)
if(treenode.left is not None):
deque.put(treenode.left)
if(treenode.right is not None):
deque.put(treenode.right)
# 说一下他们的时间复杂度和空间复杂度
# 一般来说,时间复杂度高的算法比复杂度低的算法慢
# 时间复杂度的最优,最差,和平均值
```