Implementation of the Quick Union algorithm in Ruby