BFS with single queue