Ruby data structures & algorithms questions