Skip to content

Commit

Permalink
Update dfs_recursion.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dremdeveloper authored Oct 2, 2023
1 parent 967ee42 commit 019235f
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions Algorithm_with_DataStructure/dfs_recursion.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def dfs(graph, start_node):
visited[node] = 1
print(node)
stack.extend(reversed(graph[node])) # reversed를 사용하여 깊이 우선 탐색을 유지
return visited

# 그래프를 인접 리스트로 표현
graph = {
Expand All @@ -54,6 +53,4 @@ def dfs(graph, start_node):
}

# DFS 알고리즘 실행
result = dfs(graph, 1)
print(result)
# 출력: 1 2 4 5 3
dfs(graph, 1) # 1 2 4 5 3

0 comments on commit 019235f

Please sign in to comment.