finished dfs and bfs