Given two vertices in a graph s and t, which of the two traversals (BFS and…

2025

Given two vertices in a graph s and t, which of the two traversals (BFS and DFS) can be used to find if there is a path from s to t ?

Answer: C. Both BFS and DFSBoth BFS and DFS can determine if a path exists between two vertices s and t. These traversals explore all reachable nodes from the starting vertex, so if t…

  1. A.

    Only BFS

  2. B.

    Only DFS

  3. C.

    Both BFS and DFS

  4. D.

    Neither BFS nor DFS

Attempted by 288 students.

Show answer & explanation

Correct answer: C

Both BFS and DFS can determine if a path exists between two vertices s and t. These traversals explore all reachable nodes from the starting vertex, so if t is found during traversal, a path exists.

Explore the full course: Tpsc Assistant Technical Officer

Loading lesson…