Class MysteryDisjointSetsImplementation

java.lang.Object
  extended by MysteryDisjointSetsImplementation
All Implemented Interfaces:
DisjointSets

public class MysteryDisjointSetsImplementation
extends java.lang.Object
implements DisjointSets

A mysterious implementation of the Disjoin-Sets ADT!


Constructor Summary
MysteryDisjointSetsImplementation(int N)
          Constructs a disjoint-sets structure for N items, each of which initially belongs to its own subset (all labels are different).
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MysteryDisjointSetsImplementation

public MysteryDisjointSetsImplementation(int N)
Constructs a disjoint-sets structure for N items, each of which initially belongs to its own subset (all labels are different).

Method Detail

find

public int find(int i)
Description copied from interface: DisjointSets
Returns the label of the subset containing item i.

Specified by:
find in interface DisjointSets

union

public void union(int i,
                  int j)
Description copied from interface: DisjointSets
Joins the subsets containing items i and j.

Specified by:
union in interface DisjointSets