Data Structure and algorithm with Object Oriented Design Pattern in Ruby