Question: Consider a data structure that represents a weighted undirected graph with n vertices and m edges. Suppose you want to implement the Kruskal's algorithm for
Consider a data structure that represents a weighted undirected graph with n vertices and m edges. Suppose you want to implement the Kruskal's algorithm for finding the minimum spanning tree of this graph using a disjoint-set data structure.
Assume that the disjoint-set data structure is implemented using path compression and union by rank heuristics. The algorithm sorts the edges in non-decreasing order of their weights and adds them to the tree if they do not create a cycle.
Which of the following statements is true about the time complexity of this algorithm?
A) The time complexity of the algorithm is O(mlogm) if the edges are sorted using a comparison-based sorting algorithm.
B) The time complexity of the algorithm is O(malpha(n)) where alpha(n) is the inverse Ackermann function, regardless of how the edges are sorted.
C) The time complexity of the algorithm is O(mlogn) if the edges are sorted using a comparison-based sorting algorithm.
D) The time complexity of the algorithm is O(malpha(m,n)) where alpha(m,n) is the inverse Ackermann function, if the edges are sorted using a comparison-based sorting algorithm.
Note: The inverse Ackermann function grows extremely slowly and is considered to be almost constant for all practical purposes.
Step by Step Solution
3.57 Rating (150 Votes )
There are 3 Steps involved in it
The detailed answer for the above question is provided below The correct answer B The time complexit... View full answer
Get step-by-step solutions from verified subject matter experts
