I have learnt DFS and tried to implement it. Here is my code -Ideone
The expected output should be 1 2 4 3 but my program displays 1 3 4 2.
Please help me where I have went wrong.
Thanks
I have learnt DFS and tried to implement it. Here is my code -Ideone
The expected output should be 1 2 4 3 but my program displays 1 3 4 2.
Please help me where I have went wrong.
Thanks
1 3 4 2 is also a correct DFS ordering for that graph. The difference is due to different ordering. For eg: 3gGU9L - Online C++0x Compiler & Debugging Tool - Ideone.com this outputs as you wanted
Thanks! I recently learnt it so I thought that just like a learner I might have made a mistake. Thanks again!