Implementing the find operation

Finding the subset of the given element is a recursive process that traverses the subset by following the parent elements until the current element is the parent of itself (root element):

public int find(int x) {

if (parent[x] == x) {
return x;
} else {
return find(parent[x]);
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset