BFS Memory Requirements

How large does the queue Q get?

Let a be the average size of an adjacency list Adj[u].

Let d be the current distance from S in the search.

When d is: The size of Q is:
0 1
1 a
2 O(a × a)
3 O(a × a × a)