You are given a directed-acyclic-graph G = (V,E) with possibly negative weighted edges: (a) Give an algorithm that finds the length of the shortest path that contains at most k edges between two vertices u and v in O(k(n+m)) time. (b) Give an algorithm that finds the length of the shortest path that contains exactly k edges between two vertices u and v in O(k(n+m)) time. Hint: You can solve both problems almost the same way. Modify the graph G and utilize the algorithm from problem 2 part (a).

icon
Related questions
Question

Algorithms

You are given a directed-acyclic-graph G = (V,E) with possibly negative weighted edges:
(a) Give an algorithm that finds the length of the shortest path that contains at most k
edges between two vertices u and v in O(k(n+m)) time.
(b) Give an algorithm that finds the length of the shortest path that contains exactly k
edges between two vertices u and v in O(k(n+m)) time.
Hint: You can solve both problems almost the same way. Modify the graph G and utilize the
algorithm from problem 2 part (a).
Transcribed Image Text:You are given a directed-acyclic-graph G = (V,E) with possibly negative weighted edges: (a) Give an algorithm that finds the length of the shortest path that contains at most k edges between two vertices u and v in O(k(n+m)) time. (b) Give an algorithm that finds the length of the shortest path that contains exactly k edges between two vertices u and v in O(k(n+m)) time. Hint: You can solve both problems almost the same way. Modify the graph G and utilize the algorithm from problem 2 part (a).
Expert Solution
steps

Step by step

Solved in 4 steps

Blurred answer