Holooly Plus Logo

Question 18.4: How many invocations of a single-source shortest path subrou......

How many invocations of a single-source shortest path subroutine are needed to solve the all-pairs shortest path problem? (As usual, n denotes the number of vertices.)

a) 1

b) n − 1

c) n

d) n²

(See Section 18.3.3 for the solution and discussion.)

Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

Correct answer: (c). One invocation of the single-source shortest path subroutine will compute shortest-path distances from a single vertex s to every vertex of the graph (n numbers in all, out of the n² required). Invoking the subroutine once for each of the n choices for s computes shortest-path distances for every possible origin and destination.^{20}

^{20}If the input graph has a negative cycle, it will be detected by one of the invocations of the single-source shortest path subroutine.

Related Answered Questions

Question: 18.P.4

Verified Answer:

With columns indexed by k and rows by vertex pairs...
Question: 18.P.5

Verified Answer:

With columns indexed by k and rows by vertex pairs...
Question: 18.P1

Verified Answer:

With columns indexed by i and rows by vertices: