---
# System prepended metadata

title: binary tree 的遍歷方法(level order )

---

# binary tree 的遍歷方法(level order )

固定的travel 整個樹方法

```python=

from collections import deque



if not root :
    return 

q=deque()
q.append(root_node)

while q : 
    root=q.popleft() # first in first out 
    print(root.data)  #level travel 
    if root.left:
        q.append(root.left)
    
    if root.right 
        q.append(root.right )


```