Fix small issue with bfs algorithm (#141)

Algorithm performed a dfs rather than bfs because of the queue.pop() error on line 78. Updated to queue.popleft()
pull/142/head
Rafi Barash 5 years ago committed by Louie Tan
parent 895d6f947c
commit c43337fdfb

@ -75,7 +75,7 @@ def bfs(matrix):
def traverse(i, j): def traverse(i, j):
queue = deque([(i, j)]) queue = deque([(i, j)])
while queue: while queue:
curr_i, curr_j = queue.pop() curr_i, curr_j = queue.popleft()
if (curr_i, curr_j) not in visited: if (curr_i, curr_j) not in visited:
visited.add((curr_i, curr_j)) visited.add((curr_i, curr_j))
# Traverse neighbors. # Traverse neighbors.

Loading…
Cancel
Save