Skip to main content

GATE CSE 2026Algorithms › Graph AlgorithmsVerified

GATE CSE 2026 PYQ: Let G ( V , E ) G(V, E) G ( V , E ) be an undirected, edge-weighted graph with integer weights. The weight…

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 \geq 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 \geq 0 and u∈V,dk+1(u)≤dk(u)u \in V, d_{k+1}(u) \leq 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≥0,dk(u)≤dk(v)k \geq 0, d_{k}(u) \leq d_{k}(v).

Which one of the following options is correct?

  1. A
    Only S1\text{S1} is true
    Correct answer
  2. B
    Only S2\text{S2} is true
  3. C
    Both S1\text{S1} and S2\text{S2} are true
  4. D
    Neither S1\text{S1} nor S2\text{S2} is true

Answer

(A) Only S1 \text{S1} S1 is true

Approach

S1 follows because increasing the allowed path length from k to k+1 expands the set of candidate paths, so the minimum weight cannot increase. For S2, construct a small counterexample where (u,v) lies on a shortest s-v path, but for some k the restricted shortest distance to u is larger than that to v, making S2 false.

Statement S1 is true because $d_k(u)$ is non-increasing as k increases. Statement S2 is false; in the given counterexample, (u,v) lies on a shortest path from s to v, but for k=1 we have $d_1(u)=∞$ and $d_1(v)=10$, violating $d_k(u)≤d_k(v)$. Hence only S1 is true, so the correct option is A.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.