Question:

What is the worst-case time complexity of depth first search of a graph with ‘V’ nodes and ‘E’ edges?

Show Hint

DFS uses \(O(V + E)\) because it traverses all nodes and adjacent edges.
Updated On: June 02, 2025
  • \(O(V + E)\)
  • \(O(V)\)
  • \(O(E)\)
  • \(O(V \times E)\)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

In DFS, each vertex and each edge is visited once in the worst case. Hence, the time complexity is \(O(V + E)\).
Was this answer helpful?
0
0

TS PGECET Notification