GATE CS 2026 Set 1 | Question 41

Algorithms › Graph Algorithms · MCQ · 2 marks · Answer: A

  1. Question 41Algorithmsmcq2 marks
    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 , 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 and , . S2: For every , if is part of a shortest path (in terms of weight) from to , then for every , . Which one of the following options is correct?
    • A.
      Only S1 is true
      ✓
    • B.
      Only S2 is true
    • C.
      Both S1 and S2 are true
    • D.
      Neither S1 nor S2 is true

    Answer: A

    Solution

    Answer: (A) Only S1 is true S1 is true: every path of length also has length , so allowing more edges can only keep or lower the minimum. (This is the Bellman-Ford invariant.) S2 is false. Counterexample: edges s–a (1), a–b (1), b–u (1), u–v (1), and s–v (10). The shortest path to is s-a-b-u-v with weight 4, so edge (u, v) lies on it. But with : and , so .

More GATE PYQ on Graph Algorithms

All GATE CS Algorithms PYQ →

Attempt GATE CS 2026 Set 1 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →