GATE Computer ScienceHardGATE CSE · UGC NET
Dijkstra's algorithm from vertex 0 runs on the undirected graph with edges (0,1,7), (0,2,9), (0,5,14), (1,2,10), (1,3,15), (2,3,11), (2,5,2), (3,4,6), (4,5,9). A decrease-key is counted each time the tentative distance of a vertex that already has a finite value is lowered. How many decrease-key operations occur?
- A. 3
- B. 2
- C. 4
- D. 1
Correct answer: B. 2
Tracing the run: vertex 5 is first set to 14 and lowered to 11 via vertex 2, and vertex 3 is first set to 22 and lowered to 20 via vertex 2; no other finite value improves, so the count is 2.
More Algorithms questions
- Top-down merge sort (standard two-way merge, one comparison per element moved while both lists are non-empty) sorts [38, 27, 43, 3, 9, 82…
- A fractional knapsack of capacity 20 can take items with (value, weight) = (40,8), (30,5), (24,6), (50,10), (18,3), (35,7), fractions…
- Keys 41, 22, 8, 30, 19, 52, 33, 63 are inserted in this order into an empty table of size 11 with h(k) = k mod 11 and linear probing. How…
- What is the length of the longest strictly increasing subsequence of [10, 22, 9, 33, 21, 50, 41, 60, 80, 3, 5, 70, 75, 90]?
- A directed graph on vertices 0–4 has edges 0→1 (3), 0→3 (7), 1→0 (8), 1→2 (2), 2→0 (5), 2→3 (1), 3→0 (2), 3→4 (4), 4→2 (3). What is the…
- A directed graph on vertices 0–9 has edges 0→1, 1→2, 2→0, 2→3, 3→4, 4→5, 5→3, 5→6, 6→7, 7→6, 8→7, 8→9, 9→8. How many strongly connected…