Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Union Find
Bookmark
Input
Union + Find Ops
All Separate
Custom
n
=
5
,
operations
=
[{"type":"union","x":0,"y":1},{"type":"union","x":1,"y":2},{"type":"union","x":3,"y":4},{"type":"find","x":2},{"type":"union","x":2,"y":3},{"type":"find","x":0}]
0
root
size: 1
1
root
size: 1
2
root
size: 1
3
root
size: 1
4
root
size: 1
algo
master
.
io
Step:
Initialize 5 disjoint sets - each element is its own parent
Variable
Value
n
5
currentOperation
None
Variable
Value
componentCount
5
0 / 30
Input
Union + Find Ops
All Separate
Custom
n
=
5
,
operations
=
[{"type":"union","x":0,"y":1},{"type":"union","x":1,"y":2},{"type":"union","x":3,"y":4},{"type":"find","x":2},{"type":"union","x":2,"y":3},{"type":"find","x":0}]
0 / 30
0
root
size: 1
1
root
size: 1
2
root
size: 1
3
root
size: 1
4
root
size: 1
algo
master
.
io
Step:
Initialize 5 disjoint sets - each element is its own parent
Visualization
Variables