Which data structure is used to implement depth-first search (DFS) of a graph?
2025
Which data structure is used to implement depth-first search (DFS) of a graph?
- A.
Queue
- B.
Stack
- C.
LinkedList
- D.
None of the above
Attempted by 622 students.
Show answer & explanation
Correct answer: B
Depth-first search (DFS) is implemented using a Stack. DFS visits the nodes by going as deep as possible along each path before backtracking.