Is there a way this bfs can be done without using a priority queue…

Question Answered step-by-step Is there a way this bfs can be done without using a priority queue… Is there a way this bfs can be done without using a priority queue and using a list instead?  child_parent = {} if start == goal: return [] count = 0 found = 0 # entry_finder = set() frontier = PriorityQueue() # explored = set() nodesVisited = set() curr_node = start # entry_finder.add(curr_node) # while curr_node is not goal: path = [] while frontier: # children = graph[curr_node] for child in graph[curr_node]: if child not in nodesVisited: count += 1 frontier.append((count, child)) nodesVisited.add(child) child_parent[child] = curr_node if child == goal: found = 1 break nodesVisited.add(curr_node) if found == 1: break priority, curr_node = frontier.pop() node = goal # while node is not start: while node !=start: path.append(node) node = child_parent[node] path.append(start) path.reverse() return path Computer Science Engineering & Technology Python Programming CSC 4630 Share QuestionEmailCopy link Comments (0)