GATE Computer ScienceHardGATE CS (PYQ pattern)
Floyd–Warshall is run on a 5-vertex directed graph with weight matrix (rows are sources, ∞ = no edge): row1: [0, 6, ∞, 3, ∞]; row2: [∞, 0, 2, ∞, 8]; row3: [4, ∞, 0, ∞, 1]; row4: [∞, 5, ∞, 0, ∞]; row5: [7, ∞, ∞, 2, 0]. After the iterations for intermediate vertices 1 and 2 only (k = 1, 2) have completed, what is the matrix entry D[4][5]?
- A. 8
- B. 13
- C. 15
- D. ∞
Correct answer: B. 13
Vertex 4 has the direct edge 4 → 2 of weight 5, and vertex 2 has the direct edge 2 → 5 of weight 8, so after k = 2, D[4][5] = D[4][2] + D[2][5] = 5 + 8 = 13. The value 8 is the final answer reached only after vertex 3 is used (4 → 2 → 3 → 5 = 5 + 2 + 1).
More Algorithms questions
- Six jobs have (processing time, weight): (4,3), (2,5), (7,2), (3,6), (5,4), (1,1). A single machine runs them one at a time without gaps…
- How many non-empty subsets of {3, 5, 6, 7, 9, 11, 13, 14} have an element sum divisible by 10?
- A cyclic binary string of length 12 is written around a circle, so position 12 is followed by position 1. How many of the 2¹² strings…
- What is the maximum possible sum of a non-empty contiguous circular subarray of A = [6, −4, −7, 5, 3, −2, 8, −6, 4, −1] (the array is…
- A 6 × 6 grid is given row by row, where # is a blocked cell: row1 "....#.", row2 "..#...", row3 ".#..#.", row4 "....#.", row5 "#....."…
- Twelve meetings occupy CLOSED time intervals [1,5], [2,6], [5,9], [6,7], [4,8], [7,11], [8,12], [3,10], [9,13], [10,14], [12,15], [13,16]…