What is the time complexity of BFS for a graph represented using an adjacency list?
Options
- A. O(V + E)
- B. O(VE)
- C. O(V^2E)
- D. More than one of the above
- E. None of the above
Quiz Practice:
A. O(V + E)
For an adjacency-list representation, BFS runs in O(V + E) time, where V is the number of vertices and E is the number of edges. Each vertex is visited at most once, contributing O(V), and adjacency lists are examined across all vertices, contributing O(E). Therefore, BFS is efficient for sparse graphs when adjacency lists are used.