Algorithm quick-find

Initialize

union ( a, b )
i = V[ a ]
j = V[ b ]
For each element i of V
v[ i ] * V[ a ] => v[ i ] = j

Index 1 2 3 4 5 6 7 8
group 1 2 3 4 5 6 7 8
graph (9).png

union( 2 ,6 )

union ( a=2, b=6 )
i = V[ 2 ] => i = 2
j = V[ 6 ] => j = 6
For each element i of V
v[ i ] * 2 => v[ i ] = 6

Index 1 2 3 4 5 6 7 8
group 1 6 3 4 5 6 7 8
graph (10).png

union( 4, 8 )

union ( a=4, b=8 )
i = V[ 4 ] => i = 4
j = V[ 8 ] => j = 8
For each element i of V
v[ i ] * 4 => v[ i ] = 8

Index 1 2 3 4 5 6 7 8
group 1 6 3 8 5 6 7 8
graph (11).png

union( 8, 3 )

union ( a=8, b=3 )
i = V[ 8 ] => i = 8
j = V[ 3 ] => j = 3
For each element i of V
V[ i ] * 8 => v[ i ] = 3

Index 1 2 3 4 5 6 7 8
group 1 6 3 3 5 6 7 3
graph (12).png

union( 1, 2 )

union ( a=1, b=2 )
i = V[ 1 ] => i = 1
j = V[ 2 ] => j = 6
For each element i of V
V[ i ] * 1 => v[ i ] = 6

Index 1 2 3 4 5 6 7 8
group 6 6 3 3 5 6 7 3
graph (13).png

union( 7, 5 )

union ( a=7, b=5 )
i = V[ 7 ] => i = 7
j = V[ 5 ] => j = 5
For each element i of V
v[ i ] * 7 => v[ i ] = 5

Index 1 2 3 4 5 6 7 8
group 6 6 3 3 5 6 5 3
graph (14).png]

union( 1, 5 )

union ( a, b )
i = V[ 1 ] => i = 6
j = V[ 5 ] => j = 5
For each element i of V
v[ i ] * 6 => v[ i ] = 5

Index 1 2 3 4 5 6 7 8
group 5 5 3 3 5 5 5 3
graph (15).png

union( 5, 3 )

union ( a=5, b=3 )
i = V[ 5 ] => i = 5
j = V[ 3 ] => j = 3
For each element i of V
v[ i ] * 5 => v[ i ] = 3

Index 1 2 3 4 5 6 7 8
group 3 3 3 3 3 3 3 3
graph (16).png