Skip to content

Commit

Permalink
Fix small issue with bfs algorithm (yangshun#141)
Browse files Browse the repository at this point in the history
Algorithm performed a dfs rather than bfs because of the queue.pop() error on line 78. Updated to queue.popleft()
  • Loading branch information
rafibarash authored and louietyj committed Sep 21, 2019
1 parent 895d6f9 commit c43337f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion contents/algorithms/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def bfs(matrix):
def traverse(i, j):
queue = deque([(i, j)])
while queue:
curr_i, curr_j = queue.pop()
curr_i, curr_j = queue.popleft()
if (curr_i, curr_j) not in visited:
visited.add((curr_i, curr_j))
# Traverse neighbors.
Expand Down

0 comments on commit c43337f

Please sign in to comment.