mirror of
https://github.com/dholerobin/Lecture_Notes.git
synced 2025-03-15 05:49:24 +00:00
fix oopsie
This commit is contained in:
parent
480d4cf830
commit
328ca111a5
@ -38,6 +38,7 @@ class DisjointSet(Generic[T]):
|
||||
Amortized Time Complexity per query: ~O(1)
|
||||
"""
|
||||
x, y = self.find_root(x), self.find_root(y)
|
||||
if x == y: return # if both x and y are already in the same component, do thing
|
||||
if self.size_of(x) < self.size_of(y):
|
||||
x, y = y, x # swap so that y is always the larger component
|
||||
self._parents[y] = x
|
||||
|
Loading…
x
Reference in New Issue
Block a user