Question: 1. Complete the implementation (picture above - right click and open in new tab) of Breadth First Search algorithm for finding the BFS tree search

 1. Complete the implementation (picture above - right click and open

1. Complete the implementation (picture above - right click and open in new tab) of Breadth First Search algorithm for finding the BFS tree search path for the Romania problem. Submit your code and screenshot of output.

2. For a search problem that has a branching factor is 20, if 1000 nodes can be processed per second and each node require 1kb space, what will be the (a) total number of nodes, (b) time requirement, and (c) space requirement when running a Breadth First Search algorithm at a depth of 1, 2, and 3?

8 2 4 graph["A"]-("Z", "S", "T") BFS Path from Arad to Bucharest: Queue status: + is enqueue and - is dequeue A [1 elements in queue] -A [ elements in queue] + S [2 elements in queue] - Z [2 elements in queue] 8 graph"S"] -"A", "O", "R "F 12 13 14 graph["C"]-D "R", "P") graph("P"]-("C", "R", "B") graph("R"]-("S", "P", "C") + 0 [3 elements in queue] +0 [3 elements in queue] + F [5 elements in queue] 16 graph( "B" ] ("P", "F", "G", "U") . - 0 [4 elements in queue] 18 graph("U" ] ("B", "H", "V" ) " + P [3 elements in queue] 25 def bfs(graph, start, dest): 27 print ("Queue status: + is enqueue and is dequeue") 28 frontier.put (startBFS-Path") 30 explored set() while not frontier.empty): nodestate, path-node.split() for neighbor in graph[nodestate]: if neighbor not in explored: if neighbor - dest: return path "- nodestate + "-"+ neighbor .put (neighbor "" pathnodestate) 45 print ("BFS Path from Arad to Bucharest:" 46 print bfs(grah, "A", "B) 5 49 print ("BFS Path from Faragas to Drobeta:") 5e print bfs (graph, "F", "D")) 5 8 2 4 graph["A"]-("Z", "S", "T") BFS Path from Arad to Bucharest: Queue status: + is enqueue and - is dequeue A [1 elements in queue] -A [ elements in queue] + S [2 elements in queue] - Z [2 elements in queue] 8 graph"S"] -"A", "O", "R "F 12 13 14 graph["C"]-D "R", "P") graph("P"]-("C", "R", "B") graph("R"]-("S", "P", "C") + 0 [3 elements in queue] +0 [3 elements in queue] + F [5 elements in queue] 16 graph( "B" ] ("P", "F", "G", "U") . - 0 [4 elements in queue] 18 graph("U" ] ("B", "H", "V" ) " + P [3 elements in queue] 25 def bfs(graph, start, dest): 27 print ("Queue status: + is enqueue and is dequeue") 28 frontier.put (startBFS-Path") 30 explored set() while not frontier.empty): nodestate, path-node.split() for neighbor in graph[nodestate]: if neighbor not in explored: if neighbor - dest: return path "- nodestate + "-"+ neighbor .put (neighbor "" pathnodestate) 45 print ("BFS Path from Arad to Bucharest:" 46 print bfs(grah, "A", "B) 5 49 print ("BFS Path from Faragas to Drobeta:") 5e print bfs (graph, "F", "D")) 5

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!