Union-Find
Operatrions:
Initialization:
uf := unionfind.New(6)
parent: [0, 1, 2, 3, 4, 5] index: 0 1 2 3 4 5
Find
find parent of element x
// var p int
p = uf.Find(x)
Union
Merge two node into one set
// var p, q int
uf.Union(p, q)
Implement an union-find in Go.
uf := unionfind.New(6)
parent: [0, 1, 2, 3, 4, 5] index: 0 1 2 3 4 5
find parent of element x
// var p int
p = uf.Find(x)
Merge two node into one set
// var p, q int
uf.Union(p, q)
Implement an union-find in Go.