Question: 1. Bellman-Ford (8 points) Let G - (V, E) be a weighted, directed graph that possibly has negative weights. Let |V| = n and |

 1. Bellman-Ford (8 points) Let G - (V, E) be a

1. Bellman-Ford (8 points) Let G - (V, E) be a weighted, directed graph that possibly has negative weights. Let |V| = n and | E| m, and let s E V be a source vertex Bellman-Ford's algorithm takes O(nm) time, because it makes n - 1 passes relaxing all edges. In practice, this large number of passes may not always be necessary. (a) (7 points) Suggest a simple change to the Bellman-Ford algorithm such that the algorithm does not hard-code n - 1 many passes, but that it makes only the number of passes necessary to guarantee that all d-values are correctly computed Give your answer in pseudo code. Justify why your code correctly computes the d-values (b) (1 points) How can you express the runtime of your algorithm? It should be different from O(nm) (Hint: What if you are allowed to introduce another variable, other than m and n, to express the runtime? 1. Bellman-Ford (8 points) Let G - (V, E) be a weighted, directed graph that possibly has negative weights. Let |V| = n and | E| m, and let s E V be a source vertex Bellman-Ford's algorithm takes O(nm) time, because it makes n - 1 passes relaxing all edges. In practice, this large number of passes may not always be necessary. (a) (7 points) Suggest a simple change to the Bellman-Ford algorithm such that the algorithm does not hard-code n - 1 many passes, but that it makes only the number of passes necessary to guarantee that all d-values are correctly computed Give your answer in pseudo code. Justify why your code correctly computes the d-values (b) (1 points) How can you express the runtime of your algorithm? It should be different from O(nm) (Hint: What if you are allowed to introduce another variable, other than m and n, to express the runtime

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!