update and rename Depth first search algorithm

pull/739/head
Ghada AbdulWahab 2022-04-17 03:33:12 +02:00 committed by GitHub
parent 6f17e9bf3c
commit 1eb13d9b7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -6,12 +6,12 @@ graph={
'C':['G','D'], 'C':['G','D'],
'S':['G'], 'S':['G'],
} }
#function of BFS #function of DFS
def BFS(graph,start,goal): def BFS(graph,start,goal):
Visited=[] Visited=[]
queue=[[start]] queue=[[start]]
while queue: while queue:
path=queue.pop(0) path=queue.pop()
node=path[-1] node=path[-1]
if node in Visited: if node in Visited:
continue continue