Last active
August 29, 2015 14:22
-
-
Save kartikkukreja/d844187dfcd670e1ae5b to your computer and use it in GitHub Desktop.
Depth 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
class Stack: | |
def __init__(self): | |
self.stack = [] | |
def push(self, item): | |
self.stack.append(item) | |
def pop(self): | |
return self.stack.pop() | |
def empty(self): | |
return len(self.stack) == 0 | |
def depthFirstTreeSearch(problem): | |
return treeSearch(problem, Stack()) | |
def depthFirstGraphSearch(problem): | |
return graphSearch(problem, Stack()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment