ChapQ4.2

bfs algorithm