After running Floyd-Warshall on a graph G, you want to reconstruct the shortest path from vertex u to vertex v using the predecessor matrix π. Which of the following correctly describes the path reconstruction procedure?
GATE CSE · Algorithms
Master topic for Shortest Path. Includes Dijkstra's Algorithm, Bellman-Ford Algorithm, Floyd-Warshall Algorithm.
103 questions · 0 PYQs · 20 AI practice · GATE CSE 2027
After running Floyd-Warshall on a graph G, you want to reconstruct the shortest path from vertex u to vertex v using the predecessor matrix π. Which of the following correctly describes the path reconstruction procedure?
Consider a graph with 4 vertices and the following distance matrix after Floyd-Warshall:
[[0,5,9,10],[∞,0,4,5],[∞,∞,0,1],[∞,∞,∞,0]]
How many pairs (i,j) with i ≠ j have finite shortest path distances?
In the context of Dijkstra's algorithm, which of the following statements about the shortest path tree are TRUE?
Which of the following problems can be solved using a modified version of Dijkstra's algorithm?
Which of the following correctly states the base case initialization for Floyd-Warshall?
Consider Dijkstra's algorithm on the following directed graph. Source = 1. Edges: (1,2,2), (1,3,6), (2,3,3), (2,4,8), (3,5,7), (4,5,2), (4,6,5), (5,6,1). What is the shortest distance from vertex 1 to vertex 6?
In Dijkstra's algorithm, the priority queue initially contains only the source vertex s with d[s] = 0 and all other vertices with d[v] = ∞. The algorithm terminates when the priority queue is empty. For a connected graph with V vertices and E edges, how many total extract-min operations are performed?
Floyd-Warshall is initialized with D^(0)[i][j] = w(i,j) if edge (i,j) exists, D^(0)[i][i] = 0, and D^(0)[i][j] = ∞ if no edge exists between i and j (i ≠ j). Suppose the graph has self-loops with negative weight on vertex v. How does this affect Floyd-Warshall?
Consider the following graph with 4 vertices {s, a, b, t} and directed edges: s→a (1), s→b (4), a→b (2), a→t (6), b→t (3). Dijkstra from s: what are the final shortest distances d[s], d[a], d[b], d[t]?
In Floyd-Warshall, the number of distinct subproblems (entries in the DP table indexed by k, i, j) is:
Dijkstra's algorithm is applied to an undirected graph G with V=5 vertices and the edge list: (1,2,6), (1,3,1), (1,4,5), (2,3,2), (2,5,2), (3,4,5), (3,5,6), (4,5,1). Source = 1. What is the sum of all shortest distances from vertex 1 to all other vertices?
For a graph with n vertices, the space complexity of Floyd-Warshall (storing only the distance matrix, not the path reconstruction matrix) is:
For a graph with V vertices and E edges, Dijkstra's using an adjacency matrix runs in:
What is the time complexity of Bellman-Ford algorithm?
In Floyd-Warshall algorithm, after iteration k, which of the following statements are TRUE about D[k][j] and D[i][k]?
Dijkstra's algorithm does not work correctly for graphs with:
Consider the following weighted directed graph with 3 vertices and edges: (1→2, weight 3), (2→3, weight 1), (1→3, weight 8). After running Floyd-Warshall, what is D[1][3]?
In a bio-engineering lab, researchers are mapping genetic modification pathways between bacterial strains. Each strain represents a node, and an edge between two strains indicates a modification pathway with a 'metabolic cost' (weight) for the transformation. Dijkstra's algorithm is used to find the minimum cumulative metabolic cost from a source strain 'S' to all other strains. The network and metabolic costs are as follows: S-P (3 units), S-Q (8 units), P-Q (2 units), P-R (6 units), Q-R (1 unit), Q-T (7 units), R-T (4 units).
Suppose Dijkstra's algorithm has reached an intermediate state where the tentative shortest metabolic costs are: dist[S]=0, dist[P]=3, dist[Q]=5, dist[R]=9, dist[T]=infinity. The set of strains already processed (visited) is {S, P}. The priority queue (min-heap storing (cost, strain)) contains {(5, Q), (9, R)}.
What will be the state of the priority queue and the tentative distances immediately after strain Q is extracted from the priority queue and all its unvisited neighbors have been processed?
Which of the following distinguishes Bellman-Ford algorithm from Dijkstra's algorithm?
Which of the following statements correctly distinguish Dijkstra's algorithm from the Bellman-Ford algorithm?
Want unlimited AI-generated Shortest Path questions?
Sign up free and practice with adaptive difficulty — Easy, Medium, Hard. New questions every session.
Start practising for free →