Pergunta de entrevista da empresa Yelp

Implement a breadth first search algorithm in your preferred programming language.

Resposta da entrevista

Sigiloso

22 de jul. de 2017

# Print everything in BFS def bfs(node, graph): q = [node] visited = Set() while len(q): node = q.pop(0) print node visited.add(node) for child in graph[node]: if child not in visited: q.append(child)