Which traversal technique can be used to detect a cycle in an undirected graph?

Options

  • A. DFS
  • B. Only Binary Search
  • C. Only Merge Sort
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

A. DFS

Detailed Explanation

DFS can be used to detect cycles in an undirected graph. During DFS, if an already visited adjacent vertex is encountered that is not the current vertex's parent, a cycle can be identified. Cycle detection can also be performed using other techniques, such as Disjoint Set Union in suitable undirected-graph problems. DFS-based cycle detection is an important application of graph traversal.