GATE Computer ScienceVery hardGATE CSE
A directed graph has edges S→A (4), S→B (2), B→A (−3), A→C (2), B→D (3), D→C (−5). Dijkstra's algorithm is run from S: each extracted vertex is finalised and its distance is never revised, and relaxations of finalised vertices are skipped. What distance does it report for C, and how does that compare with the true shortest distance?
- A. 0 (matches the true value)
- B. 2 (true value is 0)
- C. 1 (matches the true value)
- D. 1 (true value is 0)
Correct answer: D. 1 (true value is 0)
Dijkstra extracts B(2), A(−1), C(1) before D(5); the cheaper path S→B→D→C = 0 is never applied, so C is wrongly reported as 1 (wrong vertices: C).
More Algorithms questions
- Lomuto partition (pivot = last element, i starts at −1, for each j with A[j] ≤ pivot do i++ and swap A[i], A[j]; finally swap A[i+1] with…
- A max-heap is built from the array [3, 9, 2, 1, 4, 5, 8, 7, 6, 10] using the bottom-up procedure (sift-down from index ⌊n/2⌋−1 to 0…
- A hash table of size 11 uses double hashing with h1(k) = k mod 11 and h2(k) = 7 − (k mod 7), probing slot (h1 + i·h2) mod 11 for i = 0, 1…
- How many distinct spanning trees does the complete bipartite graph K(3,4) have?
- Floyd–Warshall is run on a 5-vertex digraph (vertices 0..4) with arc weights 0→1:3, 0→3:7, 1→0:8, 1→2:2, 2→0:5, 2→3:1, 3→0:2, 3→4:4 (no…
- In how many ways can a longest strictly increasing subsequence be chosen (counting index sets, not distinct value sequences) from the…