1.

Prim’s algorithm can be efficiently implemented using _____ for graphs with greater density.(a) d-ary heap(b) linear search(c) fibonacci heap(d) binary searchThis question was posed to me during an online exam.Query is from Minimum Spanning Tree topic in chapter Minimum Spanning Tree of Data Structures & Algorithms II

Answer»

The correct answer is (a) d-ary heap

Explanation: In Prim’s algorithm, we ADD the minimum weight edge for the chosen vertex which requires searching on the ARRAY of WEIGHTS. This searching can be efficiently IMPLEMENTED using binary heap for dense GRAPHS. And for graphs with greater density, Prim’s algorithm can be made to run in linear time using d-ary heap(generalization of binary heap).



Discussion

No Comment Found

Related InterviewSolutions