-2

Can someone please clear the use of stack in depth-first first search?

Q. How to keep a track of the visited vertices that have already been popped? Do i put it in an array or what?

Also, please tell me about the time complexity, space complexity and the use of array and link list in depth-first search

Student
  • 11

1 Answers1

1

Depth-first search-To travel as deep as possible from neighbour to neighbour before backtracking.

for further

Community
  • 1
  • 1
Hulk1991
  • 3,079
  • 13
  • 31
  • 46
  • I get that. But when all vertices have been popped out of the stack (im using stack for storing and then backtracking), what code do i write to tell the computer to that those vertices have already been visited? stupid question maybe but im new to all this with no background so please – Student Jun 12 '13 at 13:15