Implement naive DFS and BFS