Ruby implementation of the quick-union 
algorithm