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) Algorithms graph-algorithms minimum-spanning-tree time-complexity geeksforgeeks-test-series + – Hirak asked Jun 9, 2019 • retagged Jul 8, 2022 by Lakshman Bhaiya Hirak 3.7k views answer comment Share Follow See 1 comment See all 1 1 comment reply ronak.ladhar commented Sep 22, 2020 reply Follow Share Time complexity for initializing disjoint set i.e O(n) is not taken into account. Ideally time complexity should be O(n+m). Under the assumption that graph is a dense graph where m is O(n^2). Time complexity becomes O(n+n^2) = O(n^2) = O(m). 0 votes 0 votes Please log in or register to add a comment.
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. Arkaprava answered Jun 9, 2019 Arkaprava comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes Option B) O(m), as the edges are already sorted and given that union operation takes O(1) time. Sanandan answered Sep 11, 2020 Sanandan comment Share Follow See all 0 reply Please log in or register to add a comment.
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. BASANT KUMAR answered Sep 5, 2019 BASANT KUMAR comment Share Follow See all 0 reply Please log in or register to add a comment.