Professional Documents
Culture Documents
Depth First Search: Algorithm
Depth First Search: Algorithm
Search is performed by extracting and inserting from the front of the list (LIFO)
DFS progresses by expanding the first child node of the search tree that appears and
thus going deeper and deeper until a goal node is found, or until it hits a node that has
no children. Then the search backtracks, returning to the most recent node it
hasn†™t finished exploring.
Algorithm¶
Depth First Search
Let fringe be a list containing the initial state
Loop
if fringe is empty return failure
In [1]:
## declare classes of nodes,edges,and stack
In [2]:
class vertex:
def find_goal(point):
point.is_goal= True
class link: