Average of Levels in Binary Tree

Trees · BFS · Process neighbours layer by layer · Easy · about 20 min

Why it matters

The same queue pattern will unlock graph traversal later.

How it connects

DFS goes down one branch; a queue helps BFS visit a whole level before the next.

Try first

How can you remember exactly how many nodes belong to the current level?

Interview cue

The queue holds the frontier; every node enters and leaves it once.