Changed how the Visited nodes are tracked (#3811) · coderjack/algorithms-in-python@fa364df · GitHub
Skip to content

Commit fa364df

Browse files
Changed how the Visited nodes are tracked (TheAlgorithms#3811)
Updated the code to track visited Nodes with Set data structure instead of Lists to bring down the lookup time in visited from O(N) to O(1) as doing O(N) lookup each time in the visited List will become significantly slow when the graph grows
1 parent b55e132 commit fa364df

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

graphs/bfs_shortest_path.py

Lines changed: 4 additions & 12 deletions

0 commit comments

Comments
 (0)