You are not logged in. Please login at www.codechef.com to post your questions!

×

What is wrong in my implementation of DFS?

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

asked 17 May '16, 19:51

shreerockz15's gravatar image

3★shreerockz15
405
accept rate: 33%


1 3 4 2 is also a correct DFS ordering for that graph. The difference is due to different ordering. For eg: https://ideone.com/3gGU9L this outputs as you wanted

link

answered 17 May '16, 20:01

vsp4's gravatar image

6★vsp4
1.2k138
accept rate: 28%

Thanks! I recently learnt it so I thought that just like a learner I might have made a mistake. Thanks again!

(18 May '16, 00:32) shreerockz153★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,912
×1,219
×832
×726

question asked: 17 May '16, 19:51

question was seen: 562 times

last updated: 18 May '16, 00:32