DFS implementation

Does this implementation of DFS is correct or not … and if not so could anyone correct it >:)

this is the link of it.

It looks correct to me (assuming the graph has only five nodes). You should look at the recursive implementation as well(if you haven’t). It is shorter and more intuitive than using stack but also generally a tad bit slower.

ok no problem with,also look at my implementation it may helpful.
https://ideone.com/AGm2xe
1 Like
//