Shortest Paths questions

Q41

GATE CS 2026 CS-1Graph AlgorithmsMCQ2 marks−2/3 if wrong
Let G(V,E)G(V, E) be an undirected, edge-weighted graph with integer weights. The weight of a path is the sum of the weights of the edges in that path. The length of a path is the number of edges in that path.

Let s∈Vs \in V be a vertex in GG. For every u∈Vu \in V and for every k≥0k \ge 0, let dk(u)d_k(u) denote the weight of a shortest path (in terms of weight) from ss to uu of length at most kk. If there is no path from ss to uu of length at most kk, then dk(u)=∞d_k(u) = \infty.

Consider the statements:
S1: For every k≥0k \ge 0 and u∈Vu \in V, dk+1(u)≤dk(u)d_{k+1}(u) \le d_k(u).
S2: For every (u,v)∈E(u, v) \in E, if (u,v)(u, v) is part of a shortest path (in terms of weight) from ss to vv, then for every k≥0k \ge 0, dk(u)≤dk(v)d_k(u) \le d_k(v).

Which one of the following options is correct?
Show answer without attempting

Answer: A

Q37

GATE CS 2026 CS-2Graph AlgorithmsMCQ2 marks−2/3 if wrong
Let GG be a weighted directed acyclic graph with mm edges and nn vertices. Given GG and a source vertex ss in GG, which one of the following options gives the worst case time complexity of the fastest algorithm to find the lengths of shortest paths from ss to all vertices that are reachable from ss in GG?
Show answer without attempting

Answer: A

Q18

GATE CS 2025 CS-1Graph AlgorithmsMCQ1 mark−1/3 if wrong
Let GG be any undirected graph with positive edge weights, and TT be a minimum spanning tree of GG. For any two vertices, uu and vv, let d1(u,v)d_1(u, v) and d2(u,v)d_2(u, v) be the shortest distances between uu and vv in GG and TT, respectively. Which ONE of the options is CORRECT for all possible G,T,uG, T, u and vv?
Show answer without attempting

Answer: B

Q37

GATE CS 2025 CS-2Graph AlgorithmsMCQ2 marks−2/3 if wrong
Let GG be an edge-weighted undirected graph with positive edge weights. Suppose a positive constant α\alpha is added to the weight of every edge.

Which ONE of the following statements is TRUE about the minimum spanning trees (MSTs) and shortest paths (SPs) in GG before and after the edge weight update?
Show answer without attempting

Answer: C

Q59

GATE CS 2025 CS-2Graph AlgorithmsNAT2 marks
Consider the following algorithm someAlgo that takes an undirected graph GG as input.

someAlgo(GG)
1. Let vv be any vertex in GG. Run BFS on GG starting at vv. Let uu be a vertex in GG at maximum distance from vv as given by the BFS.
2. Run BFS on GG again with uu as the starting vertex. Let zz be the vertex at maximum distance from uu as given by the BFS.
3. Output the distance between uu and zz in GG.

The output of someAlgo(TT) for the tree shown in the given figure is ___________. (Answer in integer)
Question figure
Show answer without attempting

Answer: 6

Q55

GATE CS 2021 CS-2Graph AlgorithmsNAT2 marks
In a directed acyclic graph with a source vertex ss, the quality-score of a directed path is defined to be the product of the weights of the edges on the path. Further, for a vertex vv other than ss, the quality-score of vv is defined to be the maximum among the quality-scores of all the paths from ss to vv. The quality-score of ss is assumed to be 1.

The sum of the quality-scores of all the vertices in the graph shown above is ____________.
Question figure
Show answer without attempting

Answer: 929

Q40

GATE CS 2020 CSGraph AlgorithmsMCQ2 marks−2/3 if wrong
Let G=(V,E)G = (V, E) be a directed, weighted graph with weight function w:E→Rw: E \rightarrow \mathbb{R}. For some function f:V→Rf: V \rightarrow \mathbb{R}, for each edge (u,v)∈E(u, v) \in E, define w′(u,v)w'(u, v) as w(u,v)+f(u)−f(v)w(u, v) + f(u) - f(v).

Which one of the options completes the following sentence so that it is TRUE?

“The shortest paths in GG under ww are shortest paths under w′w' too, __________.”
Show answer without attempting

Answer: A

Q38

GATE CS 2016 CS-1Graph AlgorithmsNAT2 marks
Consider the weighted undirected graph with 4 vertices, where the weight of edge {i, j} is given by the entry WijW_{ij} in the matrix WW.

W=[02852058850x58x0]W = \begin{bmatrix} 0 & 2 & 8 & 5 \\ 2 & 0 & 5 & 8 \\ 8 & 5 & 0 & x \\ 5 & 8 & x & 0 \end{bmatrix}

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 ________.
Show answer without attempting

Answer: 12.0

Q14

GATE CS 2016 CS-2Graph AlgorithmsMCQ1 mark−1/3 if wrong
The Floyd-Warshall algorithm for all-pair shortest paths computation is based on
Show answer without attempting

Answer: C

Q19

GATE CS 2013 CSGraph AlgorithmsMCQ1 mark−1/3 if wrong
What is the time complexity of Bellman-Ford single-source shortest path algorithm on a complete graph of nn vertices?
Show answer without attempting

Answer: C

Q40

GATE CS 2012 CSGraph AlgorithmsMCQ2 marks−2/3 if wrong
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 vv is updated only when a strictly shorter path to vv is discovered.
Question figure
Show answer without attempting

Answer: D

0/110 correct0 marks

Related topics in Graph Algorithms