prathimacode-hub / PyAlgo-Tree

👍This project aims to be a finest hub of various data structures and algorithms using python. Feel free to contribute and show your support by ✨ this repository.
https://prathimacode-hub.github.io/PyAlgo-Tree/
MIT License
34 stars 43 forks source link

UnionFind/Disjoint Set #215

Open TheDoctor561 opened 2 years ago

TheDoctor561 commented 2 years ago

Title: Union Find Directory: Graph Name: Daniel Yu-cua


Define You:

Problem

Write to program in Python to implement a Disjoint set also known as Union Find. A disjoint set is a data structure that stores a collection of "disjoint" (non-overlapping) sets. This data structure is useful to determine whether two vertices of a graph belong to the same component, or whether an edge between them would result in a cycle. It is a key component in implementing Kruskal's algorithm to find the minimum spanning tree.

Type of change

What sort of change have you made:

Input:

UnionFind(5)
union(1,2)
union(4,5) 
isConnected(1,2)
isConnected(3,4) 

Output:

1 2 3 4 5 
1-2 3 4 5 
1-2 3 4-5
True
False

@prathimacode-hub Please assign me this issue, I'll be contributing as a Hacktoberfest 2022 participant.

welcome[bot] commented 2 years ago

Hello there! 👋🏻 Welcome to the PyAlgo-Tree! 🚀⚡️ Thank you and congrats 🎉 for opening your very first issue in this project. Please adhere to our Code of Conduct. 👍🏻 You may submit a PR if you like, make sure to follow our Pull Request Template. Feel free to get in touch with me through social media handles. Hope to see you there!😄

prathimacode-hub commented 2 years ago

Issue assigned to @TheDoctor561