GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Lazy-deletion Dijkstra (a new heap entry is pushed whenever a label improves; stale entries are skipped when popped) runs from A on the undirected graph 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 entries are pushed into the heap in total, counting the initial one for A?
- A. 11
- B. 7
- C. 10
- D. 14
Correct answer: A. 11
Every vertex gets a first label once (7 pushes, including A), and four labels improve later: C (8 → 6), E (16 → 12), F (20 → 16) and G (24 → 19), each a new push. The total is 7 + 4 = 11 (and the heap is popped 11 times).
More Algorithms questions
- A directed graph has edges 0→1 (3), 1→2 (2), 2→0 (4), 1→3 (1), 3→4 (5), 4→1 (−1), 2→4 (6), 4→0 (2), 3→0 (1). What is the minimum mean…
- How many spanning trees does K₅ minus one edge have (5 vertices, all pairs joined except one)?
- How many times does x++ execute? for (i = 1; i < 200; i = 2) for (j = i; j < 200; j += i) x++;
- The solution of the recurrence T(n) = 2T(n/2) + n/log n (with T(1) = 1, logs base 2) is:
- The solution of T(n) = 4T(n/2) + n² log n is:
- Matrices A1 to A6 have dimensions 5×40, 40×10, 10×30, 30×8, 8×25 and 25×6. The minimum number of scalar multiplications needed to compute…