14 lines
851 B
Plaintext
14 lines
851 B
Plaintext
Level order with a queue, step by step
|
|
======================================
|
|
|
|
step | action | queue (front..back) | output so far
|
|
1 | poll 1, visit, offer its children | [2 3] | [1]
|
|
2 | poll 2, visit, offer its children | [3 4 5] | [1 2]
|
|
3 | poll 3, visit, offer its children | [4 5 6] | [1 2 3]
|
|
4 | poll 4, visit, offer its children | [5 6] | [1 2 3 4]
|
|
5 | poll 5, visit, offer its children | [6 7] | [1 2 3 4 5]
|
|
6 | poll 6, visit, offer its children | [7 8 9] | [1 2 3 4 5 6]
|
|
7 | poll 7, visit, offer its children | [8 9] | [1 2 3 4 5 6 7]
|
|
8 | poll 8, visit, offer its children | [9] | [1 2 3 4 5 6 7 8]
|
|
9 | poll 9, visit, offer its children | [] | [1 2 3 4 5 6 7 8 9]
|