GateAI
Shortest Paths

GATE CSE 2020 · Q40

MCQ2 marksMedium

Time

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^{\prime}(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^{\prime} too, ___________”.

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) for every f: V → R

Shortest Paths

Let P=(v0,v1,v2,…,vk)P = (v_0, v_1, v_2, \dots, v_k) be any directed path from vertex u=v0u = v_0 to vertex v=vkv = v_k.

The total weight of path PP under the modified weight function w′w^{\prime} is given by the telescoping sum:

w′(P)=∑i=1kw′(vi−1,vi)=∑i=1k[w(vi−1,vi)+f(vi−1)−f(vi)]w^{\prime}(P) = \sum_{i=1}^k w^{\prime}(v_{i-1}, v_i) = \sum_{i=1}^k [w(v_{i-1}, v_i) + f(v_{i-1}) - f(v_i)]
w′(P)=∑i=1kw(vi−1,vi)+[f(v0)−f(v1)+f(v1)−f(v2)+⋯+f(vk−1)−f(vk)]w^{\prime}(P) = \sum_{i=1}^k w(v_{i-1}, v_i) + [f(v_0) - f(v_1) + f(v_1) - f(v_2) + \dots + f(v_{k-1}) - f(v_k)]
w′(P)=w(P)+f(u)−f(v)w^{\prime}(P) = w(P) + f(u) - f(v)

Notice that the extra term f(u)−f(v)f(u) - f(v) depends solely on the source uu and target vv, and is identical for all paths between uu and vv. Adding a constant value to every path between uu and vv does not change their relative ordering in weight.

Therefore, a path between uu and vv minimizes w(P)w(P) if and only if it minimizes w′(P)w^{\prime}(P). This property holds for every function f:V→Rf: V \rightarrow \mathbb{R}, making A the correct choice (this is the reweighting technique used in Johnson's algorithm).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Shortest Paths previous year question is Q40 of the GATE CSE 2020 paper. Find more GATE CSE PYQs on Shortest Paths in Algorithms, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 4 related Shortest Paths PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Shortest Paths in GATE CSE

Shortest Paths has 4 GATE CSE PYQs across 4 papers from 2012 to 2026. 3 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2020.

How GATE tests Shortest Paths

More from GATE CSE 2020

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2020 · Q40 · MCQ

Let G = (V, E) be a directed, weighted graph with weight function w: E → R. For some function f: V → R, for each edge (u, v) ∈ E, define w'(u, v) as 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 G under w are shortest paths under w' too, … ”.

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.