Question: Im supposed to take this Breadth First Search I've written and convert it to a Depth first search. I my understanding is I should only

Im supposed to take this Breadth First Search I've written and convert it to a Depth first search. I my understanding is I should only have to change one or two lines of code but i don't which or what to

def bfs(begin, end, grid): #begin the search Clist = [] #closed list holds nodes that have already been searched Olist = [] #open list are nodes that can still be searched current = Node(begin,None) # holds the current position

Olist.append(current) while (len(Olist)>0 and current.value != end): for node in Olist: print(node.value) print() current = Olist.pop(0) Clist.append(current) if (current.value != end): expandNode (current, grid, Clist, Olist) print(current.value) path=[]

setPath(current, path) print(path)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!