sets/quickfind

Keeps track of a set of elements partitioned into a number of disjoint (nonoverlapping) subsets. Allows to check whether the path between two nodes exists. The algorithm is inspired by Robert Sedgewick's Java implementation.
The algorithm is inspired by Robert Sedgewick's Java implementation. http://algs4.cs.princeton.edu/home/
Source:
Example
var QuickFind = require('path-to-algorithms/src/sets/quickfind').QuickFind;

var qfind = new QuickFind(10);
qfind.union(0, 1);
qfind.union(2, 1);
qfind.union(3, 4);
qfind.union(8, 9);
qfind.union(4, 8);

console.log(qfind.connected(0, 9)); // false
console.log(qfind.connected(3, 9)); // true

Classes

QuickFind