retagged by
3,665 views
4 votes
4 votes

If Kruskal’s algorithm is used for finding a minimum spanning tree of a weighted graph G with n vertices and m edges and edge weights are already given in a sorted list, then, What will be the time complexity to compute the minimum cost spanning tree given that union and find operations take amortized O(1) ?

 
A
O(m logn)
B
O(n)
C
O(m)
D
O(n logm)
retagged by

3 Answers

5 votes
5 votes
$O(m)$. Because the edge weights are already sorted, now you may have to check m of the edges in the worst case as intermediate cycles could be formed when adding an edge.
1 votes
1 votes
Option B) O(m), as the edges are already sorted and given that union operation takes O(1) time.
0 votes
0 votes
option (c) is correct if in question it is not mention that find set and union take 0(1) time then time complexty will be ElogV i.e mlogn.

Related questions

0 votes
0 votes
1 answer
1
Sumit Singh Chauhan asked Aug 18, 2018
3,526 views
What is time complexity of fun()?int fun(int n){ int count = 0; for (int i = n; i 0; i /= 2) for (int j = 0; j < i; j++) count += 1; return count;}(A) O(n^...
0 votes
0 votes
2 answers
4
Sarvottam Patel asked Jan 13, 2017
437 views
A and B are two sets. If |A| = 5 , |B| = 3 , then, the number of onto functions from A to B are ___ ?(A) 35(B) 150(C) 29(D) 27