searching for solutions returns none if no path exists ""while not self empty_frontier()path self frontier pop(self display( "expanding:",path,"(cost:",path cost,")"self num_expanded + if self problem is_goal(path end())solution found self display( self num_expanded"paths have been expanded and"len(self frontier)"paths remain in the frontier"self solution path store the solution found return path elseneighs self problem neighbors(path end()self display( ,"neighbors are"neighsfor arc in reversed(list(neighs))self add_to_frontier(path(path,arc)self display( ,"frontier:",self frontierself display( ,"no (moresolutions total of"self num_expanded,"paths expanded "note that this reverses the neigbours so that it implements depth-first search in an intutive manner (expanding the first neighbor first)and list is needed if the neighboure are generated reversing the neighbours might not be required for other methods the calls to reversed and list can be removedand the algothihm still implements depth-fist search exercise when it returns paththe algorithm can be used to find another path by calling search(again howeverit does not find other paths that go through one goal node to another explain whyand change the code so that it can find such paths when search(is called again frontier as priority queue in many of the search algorithmssuch as aand other best-first searchersthe frontier is implemented as priority queue here we use the python' built-in priority queue implementationsheapq following the lead of the python documentation /library/heapq htmla frontier is list of triples the first element of each triple is the value to be minimized the second element is unique index which specifies the order when the first elements are the sameand the third element is the path that is on the queue the use of the unique index ensures that the priority queue implementation does not compare pathswhether one path is less than another is not defined it also lets us control what sort of search ( depth-first or breadth-firstoccurs when the value to be minimized does not give unique next path version june