GATE Computer ScienceHardGATE CS (PYQ pattern)
Johnson's algorithm reweights the directed graph with edges A→B 3, A→C 8, B→D −4, C→B 10, D→C −5, D→E 2, E→A 6, C→E 1. The potentials h(v) come from Bellman–Ford from an added source with 0-weight edges to all vertices, and w′(u,v) = w(u,v) + h(u) − h(v). What is the new weight of the edge A→C?
- A. 1
- B. 8
- C. 15
- D. 19
Correct answer: C. 15
Bellman–Ford from the virtual source gives h(A) = −2, h(B) = 0, h(C) = −9, h(D) = −4, h(E) = −8. So w′(A→C) = 8 + (−2) − (−9) = 15. Using h(v) − h(u) by mistake would give 1.
More Algorithms questions
- An activity-on-arc project has events S, A, B, C, D, E, T and activities (duration): S→A 3, S→B 2, A→C 4, B→C 6, A→D 2, C→D 3, C→E 5, D→E…
- Prim's algorithm starts at A on a graph with edges AB 6, AC 1, AD 5, BC 5, BE 3, CD 7, CE 8, CF 4, DF 2, EF 9, FG 10, EG 11, DG 12, AG 13…
- A directed graph on vertices 0–4 has edges (weight): 0→1 2, 1→2 3, 0→2 9, 2→3 1, 1→3 8, 3→4 2, 2→4 7, 0→3 12, 1→4 15. What is the minimum…
- The directed graph on vertices 0–7 has edges 0→1, 1→2, 2→0, 2→3, 4→3, 4→5, 5→4, 6→5, 3→7, 7→3. For how many ordered pairs (u, v) with u ≠…
- A transformation is applied to a connected undirected graph with positive edge weights, and the result is compared with the original…
- Which of the following statements about minimum spanning trees of a connected weighted undirected graph is/are correct? I. If all edge…