<prompt> Kuandika muungano kupata algorithm katika Python.  <response>: Here is a basic implementation of the Union-Find algorithm in Python using the weighted-quick-union approach:class UnionFind: def __init__self, n: self.parent i for i in rangen self.size 1 n def findself, i: root i while root ! self.parentroot: root self.parentroot Path compression while i ! root: i, self.parenti self.parenti, root return root def connectedself, i, j: return self.findi self.findj def unionself, i, j: root_i self.findi root_j self.findj if root_i root_j: return Weighted Quick Union if self.sizeroot_i self.sizeroot_j: self.parentroot_i root_j self.sizeroot_j self.sizeroot_i else: self.parentroot_j root_i self.sizeroot_i self.sizeroot_jThe __init__ method initializes the parent and size list to hold the parent node and size of each node respectively. The find method takes an index and finds the root of the corresponding element while performing path compression. The connected method checks whether the two nodes are connected or not by checking their root. And, the union method connects the two nodes by making the root of one node the parent of the root of another node using the weighted-quick-union approach. 