data_structures/union-find.py
def union(self, p, q):
        """ Set the element which id is p to the id of q """
        savedID = self._id(p)
        targetID = self._id(q)

        for i in range(self.length):
            currentID = self.data[i]
            if currentID == savedID:
                self.data[i] = targetID
 Set the element which id is p to the id of q 
Set the element which id is p to the id of q
Set the element which id is p to the id of q
def union(self, p, q):
        savedID = self._id(p)
        targetID = self._id(q)
        for i in range(self.length):
            currentID = self.data[i]
            if currentID == savedID:
                self.data[i] = targetID
def union ( self , p , q ) : savedID = self . _id ( p ) targetID = self . _id ( q ) for i in range ( self . length ) : currentID = self . data [ i ] if currentID == savedID : self . data [ i ] = targetID
Set the element which id is p to the id of q
Set the element which id is p to the id of q
""" Set the element which id is p to the id of q """
self
p
q