In DFS, which data structure is commonly used to keep track of visited nodes?

  • Hash Table
  • Linked List
  • Queue
  • Stack
In DFS, a stack is commonly used to keep track of visited nodes. As the algorithm explores a path as deeply as possible before backtracking, a stack is ideal for maintaining the order of nodes to be visited.
Add your answer
Loading...

Leave a comment

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