1.

What is running time of Dijkstra’s algorithm using Binary min- heap method?(a) O(V)(b) O(VlogV)(c) O(E)(d) O(ElogV)The question was posed to me during an internship interview.My question is taken from Shortest Path topic in portion Shortest Path of Data Structures & Algorithms II

Answer»

Correct choice is (d) O(ElogV)

Explanation: Time required to build a binary MIN heap is O(V). Each decrease key operation TAKES O(logV) and there are still at most E such OPERATIONS. Hence TOTAL running time is O(ElogV).



Discussion

No Comment Found

Related InterviewSolutions