Which of the following graph traversal algorithms uses recursion implicitly?

Which of the following graph traversal algorithms uses recursion implicitly?

a) Breadth-First Search (BFS)
b) Depth-First Search (DFS)
c) Dijkstra’s Algorithm
d) Kruskal’s Algorithm

Answer:

b) Depth-First Search (DFS)

Explanation:

Depth-First Search (DFS) uses recursion implicitly through the system’s call stack. The algorithm explores as far as possible along each branch before backtracking, which is a natural fit for recursive function calls.

While DFS can also be implemented iteratively using an explicit stack, the recursive implementation is more intuitive as the function calls inherently handle the backtracking process.

DFS is widely used in applications such as detecting cycles in graphs, solving mazes, and performing topological sorting in directed acyclic graphs (DAGs).

Reference:

DSA (Data Structures and Algorithms) MCQ Questions and Answers

Scroll to Top