Question: Consider the recursive algorithm in Figure 10.80 for finding the shortest weighted path in an acyclic graph, from s to t. a. Why does this

Consider the recursive algorithm in Figure 10.80 for finding the shortest weighted path in an acyclic graph, from s to t.
Distance shortest( s,t ) Distance di, tmp; if( s == t ) return 0; de 00; for each Vertex v adjacent to s { tmp = shortes

a. Why does this algorithm not work for general graphs?
b. Prove that this algorithm terminates for acyclic graphs.
c. What is the worst-case running time of the algorithm?

Distance shortest( s,t ) Distance di, tmp; if( s == t ) return 0; de 00; for each Vertex v adjacent to s { tmp = shortest (v, t ); if( Cs,y + tmp < d) di = Csy + tmp; } return d;; }

Step by Step Solution

3.45 Rating (171 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a If the graph has a cycle then the recursion does not alway... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

1486-C-S-A(552).docx

120 KBs Word File

Students Have Also Explored These Related Algorithms Questions!