Binary Tree Level Order Traversal
BFS — Top-Down Level Collection
LeetCode 102 • Medium • Trees
Input: root = [3, 9, 20, null, null, 15, 7] → Output: [[3], [9,20], [15,7]]
Time
O(n)
visit each node once
Space
O(n)
queue + result
Visited: 0/5
Queue: 0
Peak Q: 0
Processing
In Queue
Processed
Edge highlight
Queue
empty
Level
[ ]
Result
[ ]
Ready
Press Play to watch BFS traverse the tree level-by-level, or Step to advance one operation at a time.
The result is built top-down using result.append(level).
The result is built top-down using result.append(level).