(20 points) We know that when we have a graph with negative edge costs, Dijkstra's algo...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(20 points) We know that when we have a graph with negative edge costs, Dijkstra's algo rithm is not guaranteed to work. (a) Does Dijkstra's algorithm ever work when some of the edge costs are negative? Explain why or why not. (b) Find an algorithm that will always find a shortest path between two nodes, under the assumption that at most one edge in the input has a negative weight. Your algorithm should run in time O(m log n), where m is the number of edges and n is the number of nodes. That is, the runnning time should be at most a constant factor slower than Dijkstra's algorithm. To be clear, your algorithm takes as input (i) a directed graph, G, given in adjacency list form. (ii) a weight function f, which, given two adjacent nodes, v, w, returns the weight of the edge between them. For non-adjacent nodes v, w, you may assume f(v, w) returns |o. (iii) a pair of nodes, s, t. If the input contains a negative cycle, you should find one and output it. Otherwise, if the graph contains at least one directed path from s to t, you should output a shortest path. Otherwise, output "No path." (c) Can you generalize your idea to graphs with two negative edges? Three? What happens to the running time as the number of edges increases? (20 points) We know that when we have a graph with negative edge costs, Dijkstra's algo rithm is not guaranteed to work. (a) Does Dijkstra's algorithm ever work when some of the edge costs are negative? Explain why or why not. (b) Find an algorithm that will always find a shortest path between two nodes, under the assumption that at most one edge in the input has a negative weight. Your algorithm should run in time O(m log n), where m is the number of edges and n is the number of nodes. That is, the runnning time should be at most a constant factor slower than Dijkstra's algorithm. To be clear, your algorithm takes as input (i) a directed graph, G, given in adjacency list form. (ii) a weight function f, which, given two adjacent nodes, v, w, returns the weight of the edge between them. For non-adjacent nodes v, w, you may assume f(v, w) returns |o. (iii) a pair of nodes, s, t. If the input contains a negative cycle, you should find one and output it. Otherwise, if the graph contains at least one directed path from s to t, you should output a shortest path. Otherwise, output "No path." (c) Can you generalize your idea to graphs with two negative edges? Three? What happens to the running time as the number of edges increases?
Expert Answer:
Answer rating: 100% (QA)
a Dijkstras algorithm doesnt always work when some of the edge costs are negative This is because Di... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Discuss the purposPrepare a liquidity analysis by computing and using the appropriate ratios to assess liquidity. Compute a minimum of three liquidity ratios for the years ended Dec 31, 20Y8 and Dec....
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Write an alternative definition that is tail-recursive (iterative) and makes use of accumulator variables. [10 marks] Explain why your alternative definition executes more efficiently. [3 marks] 1...
-
Consider the following differential equation describing a plug flow bioreactor: dy --Dy+py dt dz -(4-2)D-2uy dt where D = 0.4, 0.52/(0.1+),and the initial conditions are y(0) = 1 and z(0) = 4. a)...
-
Give an example of how goal(s) affected your motivation and performance or that of someone you work with or have worked with.
-
A pressurized steel tank is constructed with a helical weld that makes an angle a = 55° with the longitudinal axis (see figure). The tank has radius r = 0.6 m, wall thickness t = 18 mm, and...
-
On 1 January 2016, Markon plc took out a finance lease for new plant. Details of the lease are as follows: The business has a reporting-year-end date of 31 December. The minimum lease payments are...
-
Tong Company had the following two transactions related to its delivery truck. 1. Paid $45 for an oil change. 2. Paid $580 to install special gear unit, which increases the operating efficiency of...
-
Among the literature on quitting smoking are data detailing the relative successfulness of people of different ages in quitting smoking. A study of 400 adults who began various smoking-cessation...
-
What is an example of a situation where the parties work together to find a solution, brainstorm ideas so each got what they wanted most, and/or the focus was on the underlying interests of the...
-
For the plate shown below , determine the max stress and estimate of max displacement. 14 in 7 in Aluminum 6061-T6 SS plate Thickness: 0.25 in 250 lb. R=1.4 in 12 in 250 lb.
-
5. A double slit separated by 0.0580 mm is placed 1.50 m from a screen. (a) If yellow light of wavelength 588 nm strikes the double slit, what is the separation between the zeroth-order and the...
-
Lamp Light Limited (LLL) manufactures lampshades. It applies variable overhead on the basis of direct labor hours. Information from LLL's standard cost card follows: Variable manufacturing overhead...
-
The new chief executive officer(CEO) of Rafferty Manufacturing has asked for a variety of information about the operations of the firm from last year. The CEO is given the followinginformation, but...
-
PART 1 (25 marks) One Stop Invitations & More does customize, hand-crafted wedding memorabilia, in which each batch of items is a job. The company has a highly labour-intensive production process, so...
-
The courts generally prefer to follow an incremental planning ideology when deciding planning cases." Do you agree? Give reasons for your answer including reference to a range of relevant case law
-
Difference between truncate & delete
-
Visit a local supermarket and make a list of ten products manufactured outside your country.
-
What kinds of foreign exchange risk would a U.S. company face that is exporting goods to Mexico? What kinds of things would you monitor to determine what will happen to the value of the Mexican peso?
-
Extract the annual report of a Fortune Global 500 company from a country different from your home country; use the site www.glgc.com/g600.html, or...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App