Interface DisjointSets

All Known Implementing Classes:
MysteryDisjointSetsImplementation

public interface DisjointSets

Java interface for the Disjoint-Sets ADT (also known as a "union-find" data structure). This ADT represents a partitioning of some predetermined set of N items into disjoint subsets; equivalently, it represents a unique labeling of the items, where two items are considered to be in the same subset if their labels are the same. Items are referred to by arbitrary consecutive IDs from 0 up to N-1.


Method Summary
 int find(int i)
          Returns the label of the subset containing item i.
 void union(int i, int j)
          Joins the subsets containing items i and j.
 

Method Detail

find

int find(int i)
Returns the label of the subset containing item i.


union

void union(int i,
           int j)
Joins the subsets containing items i and j.