Chapter 4: Q6E (page 133)
Question: Prove that for the array prev computed by Dijkstra's algorithm, the edges form a tree.
Short Answer
All the edges form a tree follows this condition if the nodes are connected so there is no cycle.
Chapter 4: Q6E (page 133)
Question: Prove that for the array prev computed by Dijkstra's algorithm, the edges form a tree.
All the edges form a tree follows this condition if the nodes are connected so there is no cycle.
All the tools & learning materials you need for study success - in one app.
Get started for freeThere is a network of roads G=(V,E) connecting a set of cities . Each road in E has an associated length . There is a proposal to add one new road to this network, and there is a list E' of pairs of cities between which the new road can be built. Each such potential road localid="1659075853079" has an associated length. As a designer for the public works department you are asked to determine the road localid="1659075866764" whose addition to the existing network G would result in the maximum decrease in the driving distance between two fixed cities s and t in the network. Give an efficient algorithm for solving this problem.
Consider a directed graph in which the only negative edges are those that leaves; all other edges are positive. Can Dijkstra's algorithm, started at s, fail on such a graph? Prove your answer.
Suppose we want to run Dijkstra’s algorithm on a graph whose edge weights are integers in the range , where is a relatively small number.
(a) Show how Dijkstra’s algorithm can be made to run in time
(b) Show an alternative implementation that takes time just .
Here's a proposal for how to find the length of the shortest cycle in an undirected graph with unit edge lengths. When a back edge, say , is encountered during a depth-first search, it forms a cycle with the tree edges from . The length of the cycle is where the level of a vertex is its distance in the DFS tree from the root vertex. This suggests the following algorithm:
• Do a depth-first search, keeping track of the level of each vertex.
• Each time a back edge is encountered, compute the cycle length and save it if it is smaller than the shortest one previously seen. Show that this strategy does not always work by providing a counterexample as well as a brief (one or two sentence) explanation.
Suppose Dijkstra’s algorithm is run on the following graph, starting at node A.
a) Draw a table showing the intermediate distance values of all the nodes at each iteration of the algorithm.
b) Show the final shortest-path tree.
What do you think about this solution?
We value your feedback to improve our textbook solutions.