edited by
590 views
13 votes
13 votes

Which of the following statements is/are TRUE?  (Mark all the correct options)

  1. If in a depth-first traversal of a graph $G$ with $n$ vertices, $k$ edges are marked as tree edges, then the number of connected components in $G$ is $n-k-1$
  2. The tightest upper bound on the worst case time complexity in determining the existence of a cycle in an undirected graph $G = (V,E)$ is $\Theta(|V|)$
  3. The tightest upper bound on the worst case time complexity in determining the existence of a cycle in an undirected graph $G = (V,E)$ is $\Theta(|V| + |E|)$
  4. In a connected graph $G = (V,E)$ with $n$ vertices DFS will yield $n-1$ tree edges
edited by

2 Answers

6 votes
6 votes
If in a depth-first traversal of a graph $G$ with $n$ vertices, $k$ edges are marked as tree edges, then the number of connected components in $G$ is $n-k$ as each connected component of $l$ vertices gives $l-1$ tree edges. i.e.,
$$\displaystyle k = \sum_{i=1}^d l_i -1 = n - d,$$
where $d$ is the number of connected components in $G.$ So, $d = n - k$ and option A is false.

Option B is true and C is false as we can use BFS for cycle detection and though the time complexity of BFS is $\Theta(|V| + |E|),$ we can do this in $\Theta(|V|)$ as once a cycle is detected we can stop the BFS and this should happen within $O(|V|)$ time.

Option D is true.
1 votes
1 votes

For option $A$

https://gateoverflow.in/3759/gate2005-it-14

For option $B$

In a DFS of an undirected graph G, every edge of G is either a tree edge or a back edge.

If we find a back edge then there is a cycle. Now if we ever see $|V|$ distinct edges, we must have seen a back edge because in an acyclic(undirected) forest, $|E|<=V-1$

If $B$ is true, then $C$ is false.

For option $D$

False.

Answer:

Related questions