452 views
2 2 votes

The Floyd-Warshall algorithm is used on a directed graph with 4 vertices (labelled 1, 2, 3, 4). The initial shortest distances are given by an adjacency matrix where "inf" means infinity (no direct path).

The initial distances are:

  • From 1 to 1 is 0, to 2 is 8, to 3 is inf, and to 4 is 1.
     
  • From 2 to 1 is inf, to 2 is 0, to 3 is 1, and to 4 is inf.
     
  • From 3 to 1 is 4, to 2 is inf, to 3 is 0, and to 4 is inf.
     
  • From 4 to 1 is inf, to 2 is 2, to 3 is 9, and to 4 is 0.

The algorithm calculates the shortest paths by adding intermediate vertices one by one. What is the length of the shortest path from vertex 4 to vertex 1 after the algorithm has considered using vertices $\{1,2,3\}$ as intermediate points?

  1. $7$
     
  2. $9$
     
  3. $11$
     
  4. inf (infinity)

2 Answers

Answer:
Position:
Show:

Related questions

4 4 votes
1 1 answer
326
326 views
GO Classes asked Sep 18, 2025
326 views
You are given a weighted directed acyclic graph (DAG) $G=(V, E)$ with a designated source vertex $s$ and a sink vertex $t$. All edge weights are positive. We define the "...
0 0 votes
3 3 answers
625
625 views
GO Classes asked Sep 18, 2025
625 views
Imagine you have a list of jobs you can do. For each job, you know its start time, finish time, and the profit you'll earn. You cannot do two jobs if their times overlap....
4 4 votes
2 2 answers
497
497 views
GO Classes asked Sep 18, 2025
497 views
A recursive function is defined by the following recurrence relation, where $T(1)=1$:$$T(n)=T(n-1)+\log n^5$$What is the tightest asymptotic upper bound for $\mathrm{T}(\...
3 3 votes
2 2 answers
451
451 views
GO Classes asked Sep 18, 2025
451 views
Let $G=(V, E)$ be an undirected graph where every edge has a distinct positive weight.Consider any cycle, $C$, within the graph $G$. Let $e$ be the edge with the maximum ...