BinaryTree t ← 二分木を生成
# sを起点として二分木tのノードをレベル順に訪問
levelorder(s):
Queue que
que.push(s)
time ← 1
while not que.empty():
u ← que.dequeue()
L[u] ← time++
if t.nodes[u].left ≠ NIL:
que.push(t.nodes[u].left)
if t.nodes[u].right ≠ NIL:
que.push(t.nodes[u].right)
# 二分木の根を起点として訪問開始
levelorder(t.root)