What is the time complexity of Breadth-First Search (BFS) for traversing a graph with V vertices and E edges?

  • O(V * E)
  • O(V + E)
  • O(V^2)
  • O(log V)
The time complexity of BFS for traversing a graph with V vertices and E edges is O(V + E), as each vertex and edge is visited once. This linear complexity is advantageous for sparse graphs.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *