dfs vs bfs algorithm python