Question: Question 1. Write down the order in which the nodes are visited when running a) BFS, and b) DFS in the following tree (starting from

Question 1. Write down the order in which the nodes are visited when running a) BFS, and b) DFS in the following tree (starting from vertex A). When there are multiple edges, start with the edge with the lowest weight.

Question 1. Write down the order in which the nodes are visited

Question 2. Consider the recursive implementation of DFS. What would happen if you never set the visited to be true in DFS? Would the algorithm still be correct? Would it terminate? Would your answer change if you marked the visited eld to true *after* you visit all the neighbours? Give example(s) to justify your answer.

Question 3. Starting with vertex A, compute the shortest-path to all the vertices in the graph using Dikstra's algorithm

when running a) BFS, and b) DFS in the following tree (starting

Question 4. Show that Dikjstra's algorithm no longer works if the graph contains a negative-weight cycle.

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!