Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions