1.

What is the time complexity of Kruskal’s algorithm?(a) O(ElogV)(b) O(V+logE)(c) O(E+1)(d) O(V^2)I got this question in an online interview.This question is from Spanning Trees in division Trees of Discrete Mathematics

Answer»

Right answer is (a) O(ElogV)

The best explanation: In KRUSKAL’s algorithm, at each iteration, we will select the edge with the lowest WEIGHT. So, we will START with the lowest weighted edge first. After that we will select the second lowest weighted edge. In Kruskal’s algorithm, most time consuming OPERATION is sorting because the total COMPLEXITY of the Disjoint-Set operations will be O(ElogV)and it is the overall Time Complexity of the algorithm.



Discussion

No Comment Found

Related InterviewSolutions