what will happen if i run kruskal algorithm on disconected graph?? Actual problem is given n disconnected undirected graphs find kth largest value of mst of all graphs

# | User | Rating |
---|---|---|

1 | tourist | 3687 |

2 | ecnerwala | 3668 |

3 | Benq | 3503 |

4 | ksun48 | 3421 |

5 | Um_nik | 3412 |

6 | Radewoosh | 3382 |

7 | maroonrk | 3323 |

8 | ainta | 3318 |

9 | Itst | 3239 |

10 | apiadu | 3238 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 204 |

2 | SecondThread | 200 |

3 | Monogon | 196 |

4 | vovuh | 189 |

5 | Um_nik | 186 |

6 | pikmike | 185 |

7 | antontrygubO_o | 184 |

8 | Ashishgup | 181 |

9 | pashka | 169 |

10 | Radewoosh | 167 |

what will happen if i run kruskal algorithm on disconected graph?? Actual problem is given n disconnected undirected graphs find kth largest value of mst of all graphs

↑

↓

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Nov/30/2020 08:03:27 (h1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

For the first part, running Kruskal on a disconnected graph would end up finding MSTs for the individual connected components until you eventually run out of edges

.

Reason :1. You've sorted all the edges.

2. An edge Ei has to belong to any of the m(say) connected components that you have in the graph. Hence you're basically solving the problem for m graphs in one go, because since you've sorted the edges of the graph, and connected components are disjoint and have no shared edges, discarding any edge while traversing the sorted list of edges won't jeopardize MST formation of other connected components