What data structure is used to implement Depth First Search (DFS) on a graph?

  • Array
  • Linked List
  • Queue
  • Stack
Depth First Search (DFS) is typically implemented using a stack data structure. This is because DFS explores as far as possible along each branch before backtracking, which aligns well with the Last In, First Out (LIFO) nature of a stack.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *