Ruby implemented versions of Breadth and Depth first search