Undirected graph


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) \theta(n)
B) \theta(m)
C) \theta(m + n)
D) \theta(mn)


© \theta(m + n) should be the answer


Can you explain me in detail


Use DFS algorithim to find connected components with complexity © \theta(m + n) .