applications
Class FastUnionFind

java.lang.Object
  |
  +--applications.FastUnionFind

public class FastUnionFind
extends java.lang.Object


Constructor Summary
FastUnionFind(int n)
          initialize n trees, one element per tree/class/set
 
Method Summary
 int find(int theElement)
           
static void main(java.lang.String[] args)
          test program
 void union(int rootA, int rootB)
          combine trees with distinct roots rootA and rootB
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastUnionFind

public FastUnionFind(int n)
initialize n trees, one element per tree/class/set
Method Detail

find

public int find(int theElement)
Returns:
root of the tree that contains theElement

union

public void union(int rootA,
                  int rootB)
combine trees with distinct roots rootA and rootB

main

public static void main(java.lang.String[] args)
test program