GATE Computer ScienceVery hardGATE CS (PYQ pattern)
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 cost of a walk from 0 to 4 that uses exactly 3 edges?
- A. 8
- B. 12
- C. 10
- D. 14
Correct answer: B. 12
The min-plus cube of the weight matrix gives D³[0][4] = 12 (for example 0→1→3→4 = 2 + 8 + 2, 0→2→3→4 = 9 + 1 + 2, 0→1→2→4 = 2 + 3 + 7). The unrestricted shortest path 0→1→2→3→4 = 8 uses 4 edges, so it does not apply.
More Algorithms questions
- 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…
- A graph has V = 1000 vertices and E = 250000 edges. Two Dijkstra implementations are compared by counting basic steps (ignoring…
- What is the smallest m such that every simple undirected graph with 12 vertices and m edges is 2-connected (connected, and stays connected…
- Bellman–Ford is run from S on a directed graph with edges S→A 2, A→B 3, B→C −4, C→A 0, C→D 5, D→E 1, E→H 2, S→F 7, F→G −2, S→I 4, I→F 1…