Consider a data structure that represents a weighted undirected graph with n vertices and m edges. Suppose
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 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.
Data Structures and Algorithms in Java
ISBN: 978-1118771334
6th edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser