Question:hard

Let 𝐺(𝑉, 𝐸) 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 π‘ βˆˆπ‘‰ be a vertex in 𝐺. For every π‘’βˆˆπ‘‰ and for every π‘˜ β‰₯0, let π‘‘π‘˜(𝑒) denote
the weight of a shortest path (in terms of weight) from 𝑠 to 𝑒 of length at most π‘˜. If
there is no path from 𝑠 to 𝑒 of length at most π‘˜, then π‘‘π‘˜(𝑒) = ∞.
Consider the statements:
S1:
For every π‘˜ β‰₯0 and 𝑒 βˆˆπ‘‰, π‘‘π‘˜+1(𝑒) β‰€π‘‘π‘˜(𝑒).
S2:
For every (𝑒, 𝑣) ∈𝐸, if (𝑒, 𝑣) is part of a shortest path (in terms of
weight) from 𝑠 to 𝑣, then for every π‘˜β‰₯ 0, π‘‘π‘˜(𝑒) β‰€π‘‘π‘˜(𝑣).
Which one of the following options is correct?

Show Hint

Compare the set of length-at-most-k paths to length-at-most-(k+1) paths for S1 (superset argument), and try building a graph where the predecessor u on the shortest weighted path to v needs more edges to reach than a direct shortcut to v needs, to test S2.
Updated On: Aug 3, 2026
  • Only S1 is true
  • Only S2 is true
  • Both S1 and S2 are true
  • Neither S1 nor S2 is true
Show Solution

The Correct Option is A

Solution and Explanation

Step 1: Think of \(d_k(u)\) as the result of running \(k\) rounds of Bellman-Ford-style edge relaxation starting from \(s\): after \(k\) rounds, \(d_k(u)\) is the cheapest weight found for reaching \(u\) using paths of at most \(k\) edges.

Step 2: Why S1 must hold. Doing one extra round of relaxation can only keep values the same or make them smaller, never larger, because every path counted in round \(k\) is still counted in round \(k+1\) (using at most \(k\) edges is a special case of using at most \(k+1\) edges). Formally, since paths of length \(\le k\) form a subset of paths of length \(\le k+1\), taking the minimum weight over the larger set can never exceed the minimum over the smaller set: \(d_{k+1}(u) \le d_k(u)\). This is true for any weights and any \(k\), so S1 is correct.

Step 3: Why S2 can break. S2 tries to say that if \(u\) immediately precedes \(v\) on the best route to \(v\), then at every stage of relaxation \(u\)'s tentative distance is at most \(v\)'s. But nothing forces \(u\) to be reachable quickly in terms of edge count - \(u\) might sit deep inside the graph (many edges away from \(s\)) even though the edge \((u,v)\) happens to close out the cheapest overall route to \(v\).

Step 4: A working counterexample. Take a chain \(s \to y \to u\) (weights 1 and 1) plus the edge \(u \to v\) of weight 0, so the path \(s,y,u,v\) costs \(2\) over 3 edges. Also add a shortcut \(s \to v\) directly with weight \(5\). Because \(2 < 5\), the true shortest path to \(v\) passes through \(u\), satisfying S2's condition on edge \((u,v)\).

Step 5: Break it at \(k=1\). With only 1 edge allowed, \(u\) is unreachable (\(u\) needs 2 edges via \(y\)), so \(d_1(u)=\infty\). But \(v\) is reachable in 1 edge directly, so \(d_1(v)=5\). Since \(\infty \le 5\) is false, S2 fails for this \(k\).

Step 6: Final call. S1 is a universal truth about relaxation with more allowed edges; S2 fails once the predecessor on the shortest path is edge-count-wise farther from \(s\) than the successor. So the correct choice is 'Only S1 is true', i.e. option A.

Was this answer helpful?
0


Questions Asked in GATE CS exam