Practice free →
HomeGATE CSEcomputerscienceAlgorithms › The 'relax' operation on edge (u, v) with weight…

The 'relax' operation on edge (u, v) with weight w updates d[v] when

Ad[u] + w < d[v]; path via u is shorter than current best
Bv has not been visited yet, regardless of distance
Cu is the source vertex
Dthe edge has the smallest weight in the graph
Answer & Solution
Correct answer: A. d[u] + w < d[v]; path via u is shorter than current best
Relaxation: if reaching v via u (distance d[u] + w) is shorter than the current best d[v], update d[v] = d[u] + w. This is the only update step; otherwise leave d[v] alone. The 'visited yet' or 'is source' or 'smallest weight' tests are unrelated to relaxation logic.
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions