Skip to content
Related Articles

Related Articles

GATE | GATE CS 2008 | Question 85

View Discussion
Improve Article
Save Article
  • Last Updated : 28 Jun, 2021

The most efficient algorithm for finding the number of connected components in an undirected graph on n vertices and m edges has time complexity

(A) &thetha;(n)
(B) &thetha;(m)
(C) &thetha;(m + n)
(D) &thetha;(mn)

Answer: (C)

Explanation: Number of connected components in undirected graph can simply calculated by doing a BFS or DFS. The best possible time complexity of BFS and DFS is O(m + n).

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!