Shortest Path · Algorithms
22 questions · asked in 17 of 27 years (2000–2026)
MCQ 21 · NAT 11-mark 12 · 2-mark 10
2000Questions per year2026
Questions 6–10 of 22
Let be a directed, weighed graph with weight function . For some function , for each edge , define as .
Which one of the options completes the following sentence so that it is TRUE?
"The shortest paths in G under are shortest paths under too,_________".
Which one of the options completes the following sentence so that it is TRUE?
"The shortest paths in G under are shortest paths under too,_________".
Answer: (A)
Take any path . The f-terms cancel in pairs, so:
Every s-to-t path changes by the same constant . So the shortest path stays the shortest, for any f. (This is the reweighting trick used in Johnson's algorithm.)
Answer: for every
Every s-to-t path changes by the same constant . So the shortest path stays the shortest, for any f. (This is the reweighting trick used in Johnson's algorithm.)
Answer: for every
Consider the weighted undirected graph with 4 vertices,where the weigh to edge {i, j} is given by the entry Wij in the matrix W.
The largest possible integer value of x, for which at least one shortest path between some pair of vertices will contain the edge with weight x is ____.
The largest possible integer value of x, for which at least one shortest path between some pair of vertices will contain the edge with weight x is ____.
Answer: 12
Weights: .
Pair (3, 4). The routes that avoid the edge are 3-2-1-4 with weight , 3-1-4 with , and 3-2-4 with . (3-1-2-4 is longer.) The shortest is 12, so the edge of weight lies on a shortest 3-4 path (a tie counts) only if .
Other pairs. For (1, 3) the route through is 1-4-3 with weight , and the route 1-2-3 weighs 7, so this needs . For (2, 4) the route 2-3-4 weighs and 2-1-4 weighs 7, so again . For (1, 4), (2, 3) and (1, 2) a route through is never shorter than the best other route. So these pairs give smaller bounds.
So the largest integer is 12.
Answer: 12
Pair (3, 4). The routes that avoid the edge are 3-2-1-4 with weight , 3-1-4 with , and 3-2-4 with . (3-1-2-4 is longer.) The shortest is 12, so the edge of weight lies on a shortest 3-4 path (a tie counts) only if .
Other pairs. For (1, 3) the route through is 1-4-3 with weight , and the route 1-2-3 weighs 7, so this needs . For (2, 4) the route 2-3-4 weighs and 2-1-4 weighs 7, so again . For (1, 4), (2, 3) and (1, 2) a route through is never shorter than the best other route. So these pairs give smaller bounds.
So the largest integer is 12.
Answer: 12
Consider the tree arcs of a BFS traversal from a source node W in an unweighted, connected, undirected graph. The tree T formed by the tree arcs is a data structure for computing
Answer: (B)
In an unweighted graph, BFS starts at W and visits the vertices one level at a time. So the tree path from W to any vertex v uses the fewest possible edges.
The tree does not give the shortest paths between other pairs of vertices.
Answer: the shortest path from W to every vertex in the graph
The tree does not give the shortest paths between other pairs of vertices.
Answer: the shortest path from W to every vertex in the graph
What is the time complexity of Bellman-Ford single-source shortest path algorithm on a complete graph of n vertices?
Answer: (C)
The running time of Bellman-Ford is . In a complete graph, the number of edges is .
Time for n vertices:
Final answer:
Time for n vertices:
Final answer:
Consider the directed graph shown in the figure below. There are multiple shortest paths between vertices S and T. Which one will be reported by Dijkstra's shortest path algorithm? Assume that, in any iteration, the shortest path to a vertex v is updated only when a strictly shorter path to v is discovered
Answer: (D)
Run Dijkstra from S: B = 3, A = 4, D = 7 (via S).
- Take B: D via B is 7, not strictly shorter, so D's parent stays S.
- Take A: C = 5. Take C: E = 6 (D via C is 8, no change).
- Take E: T = 10 (via E), G = 8.
- Take D: T via D is 10, not strictly shorter, so T's parent stays E.
Path: S A C E T
Answer: SACET
- Take B: D via B is 7, not strictly shorter, so D's parent stays S.
- Take A: C = 5. Take C: E = 6 (D via C is 8, no change).
- Take E: T = 10 (via E), G = 8.
- Take D: T via D is 10, not strictly shorter, so T's parent stays E.
Path: S A C E T
Answer: SACET
Keep practising