Which of the following statements about DFS are correct? A. It can detect…

2025

Which of the following statements about DFS are correct?

A. It can detect cycles in a graph

B. It can be used to find connected components.

C. It works for both directed and undirected graph.

D. Guarantees shortest path in unweighted graphs.

Choose the correct answer from the options given below:

Answer: A. A, B, C OnlyDFS detects cycles by identifying back edges during traversal, making statement A correct. It visits all reachable vertices to identify connected components,…

  1. A.

    A, B, C Only

  2. B.

    A, B, C, D

  3. C.

    C, D Only

  4. D.

    B, C Only

Attempted by 304 students.

Show answer & explanation

Correct answer: A

DFS detects cycles by identifying back edges during traversal, making statement A correct.

It visits all reachable vertices to identify connected components, validating statement B.

DFS functions on both directed and undirected graphs as stated in C.

However, BFS guarantees shortest paths in unweighted graphs, not DFS, invalidating statement D.

Therefore, the correct combination includes A, B, and C.

Explore the full course: Tpsc Assistant Technical Officer

Loading lesson…