The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+18 votes
1.5k views

Suppose we run Dijkstra’s single source shortest-path algorithm on the following edge-weighted directed graph with vertex P as the source.

     

In what order do the nodes get included into the set of vertices for which the shortest path distances are finalized?

  1. P,Q,R,S,T,U
  2. P,Q,R,U,S,T
  3. P,Q,R,U,T,S
  4. P,Q,T,R,U,S
asked in Algorithms by Veteran (59.4k points) | 1.5k views

2 Answers

+18 votes
Best answer

Ans is (B). In Dijkstra's algorithm at each point we choose the smallest weight edge which starts from any one of the vertices in the shortest path found so far and add it to the shortest path.

answered by Junior (749 points)
edited by
0
Ans (C) is also possible in this case.. so, what is the answer ? confused about it.
0
(c )can not be an answer  according to dijikstras algorithm

reaching node R  , edge to S and U from R is relaxed which gives node S value - 4 and node U value as 3 therefore we wil choose U now and after that  S and at the and T
+5 votes

Answer will be "B" 

answered by Loyal (7.7k points)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

35,506 questions
42,827 answers
121,678 comments
42,181 users