Last active
August 29, 2015 14:22
-
-
Save kartikkukreja/41b2f77a279f43920da8 to your computer and use it in GitHub Desktop.
Breadth First Search Algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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