1.

Prim’s algorithm can be implemented using _______(a) a stack data structure(b) radix sort(c) priority queue data structure(d) bubble sortI have been asked this question in a national level competition.My query is from Spanning Trees in division Trees of Discrete Mathematics

Answer»

Correct answer is (c) priority QUEUE data structure

Easy explanation: The time complexity of Prim’s algorithm depends on the data structures used for the graph and for ORDERING the edges by weight, which can be done USING a priority queue. In GENERAL, a priority queue will be quicker at finding the vertex in the SPANNING tree with minimum cost. The choice of data structures for implementation will lead to varying time complexity.



Discussion

No Comment Found

Related InterviewSolutions