깊이 우선 탐색2 [LEET CODE] 78. Subsets # Problem Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Constraints: 1 2021. 4. 9. [코딩 + 알고리즘 완주반] 20일차. 너비 우선 탐색(Breadth-First Search ), 깊이 우선 탐색(Depth-First Search) # 너비 우선 탐색 (BFS) 정점들과 같은 레벨에 있는 노드들을 먼저 탐색 # 깊이 우선 탐색 (DFS) 정점의 자식들을 먼저 탐색하는 방식 # BFS 알고리즘 구현 자료구조 큐 활용 graph = dict() graph['A'] = ['B', 'C'] graph['B'] = ['A', 'D'] graph['C'] = ['A', 'G', 'H', 'I'] graph['D'] = ['B', 'E', 'F'] graph['E'] = ['D'] graph['F'] = ['D'] graph['G'] = ['C'] graph['H'] = ['C'] graph['I'] = ['C', 'J'] graph['J'] = ['I'] def bfs(graph, start_node): visited = list() need.. 2021. 4. 6. 이전 1 다음 반응형