DisjSetsFast - package DataStructures; / / / / / / / / /...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
package DataStructures; // DisjSetsFast class // // CONSTRUCTION: with int representing initial number of sets // // ******************PUBLIC OPERATIONS********************* // void union( root1, root2 ) --> Merge two sets // int find( x ) --> Return set containing x // ******************ERRORS******************************** // No error checking is performed /** * Disjoint set class, using union by rank * and path compression. * Elements in the set are numbered starting at 0. * @author Mark Allen Weiss */ public class DisjSetsFast { /** * Construct the disjoint sets object. * @param numElements the initial number of disjoint sets. */ public DisjSetsFast( int numElements ) { s = new int [ numElements ]; for( int i = 0; i < s.length; i++ ) s[ i ] = -1; } /** * Union two disjoint sets using the height heuristic. * For simplicity, we assume root1 and root2 are distinct * and represent set names. * @param root1 the root of set 1.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/22/2011 for the course CSC 532 taught by Professor Dr.gursaranadhar during the Spring '07 term at University of North Carolina Wilmington.

Page1 / 2

DisjSetsFast - package DataStructures; / / / / / / / / /...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online