Dijkstra Wrong Answer

https://ide.codingblocks.com/s/65081

Please Reply…

Hi Monika, there are various stages where your code went off track. These are:

  1. Line No. 41: The value of distance of root node also sets to 10000 instead of 0.

  2. You need to maintain 2 sets and wait till all of the nodes in second set gets transferred to first set < set s in your case >.

  3. This brings us to third thing which is termination condition of while loop. It shall not be checking for s.empty().

I suggest you read the algorithm again. If you still got any doubt respond to this thread.

Hope this helps :slight_smile:

Hey Monika, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.