Which data structure is primarily used by the Depth-First Search (DFS) algorithm?
A
Queue
B
Hash Table
C
Stack
D
Heap
Correct Answer: Option C — Stack
Explanation:
Depth-First Search (DFS) uses a stack to keep track of nodes during traversal. The algorithm explores one branch of a graph or tree as deeply as possible before backtracking to explore other branches. DFS can use an explicit stack or the system's call stack through recursion. This approach is useful for pathfinding, graph traversal, cycle detection, and topological sorting.