completed DFS/BFS