GATE Computer ScienceVery hardGATE CS
A directed graph has edges (weights): S→A 2, S→B 2, S→C 3, A→D 2, A→E 3, B→D 2, B→E 1, B→F 3, C→E 1, C→F 2, D→T 2, E→T 3, F→T 1. How many distinct shortest paths are there from S to T?
- A. 3
- B. 4
- C. 6
- D. 5
Correct answer: D. 5
The shortest distance to T is 6. Number of shortest paths: ways(A) = ways(B) = ways(C) = 1; D at distance 4 from A and B gives ways(D) = 2; E at distance 3 only via B gives 1; F at distance 5 via B and C gives 2. T at 6 receives D (2) + E (1) + F (2) = 5.
More Algorithms questions
- Twelve keys 24, 17, 31, 9, 22, 5, 38, 13, 2, 27, 6, 20 are used to build a min-heap in an array in two ways: (1) by inserting them one at…
- Which is the tight asymptotic solution of T(n) = T(n/3) + T(2n/3) + n/log₂ n (with T(1) = 1)?
- A flow network has directed edges (capacity): s→a 4, s→b 3, a→b 2, a→c 2, b→c 2, b→d 3, c→t 4, d→t 2, c→d 1. Let F be the maximum s–t flow…
- For the Petersen graph (10 vertices, 15 edges, 3-regular, independence number 4), let VC be the size of a minimum vertex cover and MM the…
- Binary insertion sort sorts 10 distinct elements. It inserts the k-th element into the sorted prefix of k − 1 elements by binary search…
- A sorted array holds 1000 distinct elements and binary search (one three-way comparison per probe) is applied. What is the worst-case…