GATE Computer ScienceHardGATE CS (PYQ pattern)
Dijkstra's algorithm (never re-inserting or re-opening a vertex once it has been extracted) is run from S on a directed graph with edges S→A 4, S→B 5, A→C 3, B→A −3, B→D 6, C→D −2, C→T 8, D→T 3. What distance label does it finally assign to T?
- A. 6
- B. 8
- C. 7
- D. 5
Correct answer: B. 8
Dijkstra extracts S, A (4), B (5), C (7), D (5, improved from 11 through C) and finally T with 8. It never reopens A after the negative edge B→A, so A, C, D and T keep labels that are too large. The true shortest distance is 6 via S→B→A→C→D→T (5 − 3 + 3 − 2 + 3).
More Algorithms questions
- Dijkstra's algorithm with a binary min-heap (lazy insertion is not used: a decrease-key is performed whenever an edge improves the label…
- In the undirected weighted graph with edges SA 1, SB 1, SC 2, AD 2, BD 2, CD 1, AE 3, BE 3, CE 2, DT 2, ET 1 and AB 1, how many distinct…
- Bellman–Ford is run from A on a 6-vertex graph with directed edges relaxed in this fixed order in every pass: E→F 2, D→E 3, C→D 2, B→C 4…
- A weighted undirected graph has vertices A–F and edges AB 1, BC 1, CA 1, CD 2, DE 2, EC 2, EF 3, FD 3, AF 7. How many distinct minimum…
- A weighted undirected graph on vertices A–G has edges AB 4, AC 8, BC 2, BD 5, CD 9, CE 10, DE 3, DF 11, EF 4, EG 7, FG 5, BG 20. Its MST…
- How many spanning trees does the wheel graph W₅ have (a hub joined to every vertex of a 5-cycle: 6 vertices, 10 edges)?