Let's look at the road that connects intersections 2
and 3
. Since they're in separate neighborhoods, it's time for another merge!
Step 1: Yet Another Merge with Union(2, 3)
We're now bringing the neighborhoods of 2
and 3
together. Keep in mind that 2
already represents the large neighborhood {0, 1, 2}
.
New Update on the Investigation Board
Step 2: What Does the Parent Array Say Now?
By replacing the value under 2
with 3
, we signify that 3
is the new head of this even larger neighborhood, representing the union set {0, 1, 2, 3}
. It's as if 3
is the new community leader, bringing together various smaller communities into one.
Step 3: The Next Piece of the Puzzle - Edge (1, 4)
We've come a long way, but our investigation isn't over. Our next clue is the road connecting intersections 1
and 4
.
1Find(1) = 3 # Intersection 1 is part of the neighborhood led by 3.
2Find(4) = 4 # Intersection 4 is its own neighborhood for now.
Will 4
become part of this sprawling neighborhood, or does it belong to another? Is the mystery of the loop about to be solved, or are we still in the clear?