Start learning →

Per the lecture's guidance, choose Kruskal over Prim when

Athe graph has negative edge weights
Bthe source vertex is fixed in advance
Cyou need shortest paths from a single source
Dthe graph is sparse and the edge list is natural
Answer & Solution
Correct answer: D. the graph is sparse and the edge list is natural
On sparse graphs Kruskal's O(E log V) wins because sorting a small edge list is cheap. On dense graphs (E close to V²) Prim with a Fibonacci heap gives O(V²), beating Kruskal's O(V² log V). Negative weights and source vertices are irrelevant for MST shortest-path-from-source is Dijkstra, a different algorithm.
Practise this question with Quill — GATE CSE →

Keep practising Algorithms

Browse all Algorithms questions for GATE CSE, or explore more Computer Science topics.

Start a Algorithms lesson →
Related questions