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'],
'S':['G'],
}
#function of BFS
#function of DFS
def BFS(graph,start,goal):
Visited=[]
queue=[[start]]
while queue:
path=queue.pop(0)
path=queue.pop()
node=path[-1]
if node in Visited:
continue
@ -29,4 +29,4 @@ def BFS(graph,start,goal):
Solution=BFS(graph,'S','G')
print('Solution is ',Solution)
print('Solution is ',Solution)