rewrite questions in BFS and DFS