Skip to content

Instantly share code, notes, and snippets.

@kartikkukreja
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save kartikkukreja/41b2f77a279f43920da8 to your computer and use it in GitHub Desktop.

Select an option

Save kartikkukreja/41b2f77a279f43920da8 to your computer and use it in GitHub Desktop.
Breadth First Search Algorithm
from collections import deque
class Queue:
def __init__(self):
self.queue = deque()
def push(self, item):
self.queue.append(item)
def pop(self):
return self.queue.popleft()
def empty(self):
return len(self.queue) == 0
def breadthFirstGraphSearch(problem):
return graphSearch(problem, Queue())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment