Match List - I with List - II. Choose the correct answer from the options given below :List - I List - II (A) Dijkstra’s Algorithms (I) Find the shortest path between all pairs of vertices in a graph with positive or negative edge weights. (B) Floyd-Warshall Algorithms (II) Finds the shortest path in a weighted graph with non-negative edge weights. (C) Bellman-frod Algorithms (III) Grows a spanning tree by repeatedly adding the smallest edge to a neighboring vertex. (D) Prim’s Algorithms (IV) Finds the shortest paths from a single source in a directed graph with negative edge weights.
(A)-(II), (B)-(I), (C)-(IV), (D)-(III)
The list contrasts classic graph algorithms: single-source and all-pairs shortest paths, and a greedy tree-growing method.
(A) Dijkstra’s algorithm — greedy single-source shortest paths; correct only when every edge weight is non-negative: (A)-(II).
(B) Floyd-Warshall algorithm — dynamic programming over intermediate vertices that gives the shortest path between all pairs of vertices, with positive or negative edge weights (no negative cycle): (B)-(I).
(C) Bellman-Ford algorithm — relaxes every edge V−1 times, finds single-source shortest paths in a directed graph even when some edge weights are negative, and detects negative cycles: (C)-(IV).
(D) Prim’s algorithm — grows a minimum spanning tree by repeatedly adding the smallest edge that joins the tree to a neighbouring vertex: (D)-(III).
Codes that give Dijkstra the all-pairs description or Floyd-Warshall the non-negative single-source description swap the two shortest-path methods, and the code (C)-(III), (D)-(IV) gives Bellman-Ford the spanning-tree step and Prim the negative-weight shortest-path task, both of which belong to the other algorithm.
(A)-(II), (B)-(I), (C)-(IV), (D)-(III) option is correct.
Floyd-Warshall algorithm utilizes __________ to solve the all-pairs shortest paths problem on a directed graph in __________ time.
An all-pairs shortest-paths problem is efficiently solved using :
Floyd-Warshall algorithm utilizes __________ to solve the all-pairs shortest paths problem on a directed graph in __________ time.
An all-pairs shortest-paths problem is efficiently solved using :