1

I'm not getting the idea that DFS is not complete because it could stuck in infinite loops.

Here is an answer from another question

If the graph has cycles, then a depth first search could get stuck in a cycle before finding the desired element.

And this answer is the same as in my AI book. But in my Algorithms book i'm pretty sure DFS never goes into an infinite cycles, because an explored node it will be marked as visited, so that the algorithm well never reinsert it in the stack again?

Please correct me if i'm wrong ?

Dominique Fortin
  • 2,212
  • 15
  • 20
Mohamed Horani
  • 544
  • 3
  • 9
  • 23
  • Is it *your* implementation of the DFS, or are you using something from an existing library? If the former, it would be good to post some of your code. If the latter, then which library? – vsz Mar 21 '16 at 05:12
  • i'm not implementing anything!!! i'm talking about theoretical computer science. i.e. pseudocode and from book to another book the pseudocode differs, but the idea is the same, that's why i haven't pasted them here. – Mohamed Horani Mar 21 '16 at 05:31
  • 1
    In that case I would recommend http://cs.stackexchange.com because this site is about actual programming. As the question is formed it seems to be about your code not running properly and you asking for help with a specific error in your code. You will have much higher chances of getting people to notice your question if it was posted to the right site and if it was clear that you are interested in the theory and not a specific coding solution. (by the way, a *properly* implemented depth first search shouldn't enter a cycle, if it was clear that cycles can exist in your data structure) – vsz Mar 21 '16 at 05:52

0 Answers0