GATE | GATE CS 2008 | Question 85
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
Recommended Posts:
- GATE | GATE CS 2008 | Question 52
- GATE | GATE CS 2008 | Question 53
- GATE | GATE CS 2008 | Question 54
- GATE | GATE CS 2008 | Question 55
- GATE | GATE CS 2008 | Question 56
- GATE | GATE CS 2008 | Question 85
- GATE | GATE CS 2008 | Question 58
- GATE | GATE CS 2008 | Question 59
- GATE | GATE CS 2008 | Question 85
- GATE | GATE CS 2008 | Question 61
- GATE | GATE CS 2008 | Question 62
- GATE | GATE CS 2008 | Question 64
- GATE | GATE CS 2008 | Question 85
- GATE | Gate IT 2008 | Question 82
- GATE | Gate IT 2008 | Question 81



