Skip to content

Commit 82b29de

Browse files
Fix Non Recursive Depth First Search
1 parent 01606c6 commit 82b29de

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

graphs/depth_first_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def depth_first_search(graph: Dict, start: str) -> Set[int]:
4040
# 1) pop last element instead of first one
4141
# 2) add adjacent elements to stack without exploring them
4242
for adj in reversed(graph[v]):
43-
if adj not in explored:
43+
if adj not in explored:
4444
stack.append(adj)
4545
return explored
4646

0 commit comments

Comments
 (0)