1,180 views
1 votes
1 votes

what is the time-complexity in kruskal algorithm for the overall step 2 where for each vertex Make-set function is called ? How come overall time for this step  is O(v log v) ? 

We are performing this Operation for all the vertices in the Initial phase only so for every iteration , we have a single set for one vertex so in each iteration we are making one set for one element so how come overall time is O(vlogv) ?
We perform Make-set operation only once right because after we come out of loop we have v sets of 1 vertex each .

Please explain this clearly .

2 Answers

0 votes
0 votes
select  all vertices through makeset will take time O(V)

and for checking cycle detection it use path compression algorithm ,it takes O(log V)

so overall complexity is O(V logV)

Related questions

3 votes
3 votes
3 answers
2
firki lama asked Jan 12, 2017
13,368 views
i know time complexity is O(nlogn) but can upper bound given in question consider as TRUE..
0 votes
0 votes
2 answers
3
radha gogia asked Aug 5, 2015
2,169 views
Does it tale constant time or the time taken proportional to search in the entire partition of elements to find whether the component lies in that same component or not ?...
2 votes
2 votes
1 answer
4