Read this article and make sure you know the differences between depth-first and breadth-first search algorithms.