GATE Computer ScienceHardGATE CS (PYQ pattern)
Dijkstra's algorithm with a binary min-heap (lazy insertion is not used: a decrease-key is performed whenever an edge improves the label of a vertex that is already in the heap) is run from A on an undirected graph with 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. How many decrease-key operations are performed in total?
- A. 3
- B. 5
- C. 6
- D. 4
Correct answer: D. 4
Order of extraction: A(0), B(4), C(6), D(9), E(12), F(16), G(19). Decrease-keys of labels already in the heap occur for C (8 → 6), E (16 → 12), F (20 → 16) and G (24 → 19): four in all, counted by simulating the algorithm. The labels of D (9) and the later extractions need no decrease.
More Algorithms questions
- 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)?
- How many spanning trees does the 3-dimensional hypercube Q₃ (8 vertices, 12 edges) have?