In DFS, the time complexity is _______ in the worst case for traversing a graph with V vertices and E edges.

  • O(E)
  • O(V * E)
  • O(V + E)
  • O(V)
The time complexity of DFS in the worst case is O(V + E), where V is the number of vertices and E is the number of edges in the graph. This is because DFS visits each vertex and edge exactly once in the worst case.
Add your answer
Loading...

Leave a comment

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