Program is now working for breadth-first search.