/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q1E Suppose Dijkstra’s algorithm i... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

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.

Short Answer

Expert verified

(a)The table showing the intermediate distance values is as follows.


(b)The final shortest-path tree is as follows:

Step by step solution

01

Explain Dijkstra’s algorithm

Dijkstra’s shortest-path algorithm marks all the distance of all the vertices as infinity. As the algorithm runs, when each vertex is visited, the distance between the vertices is calculated and the lowest distance values are updated at each iteration.

02

Show a table showing the intermediate distance values of all the nodes.

(a)

Consider the given graph ,

Set A as the starting node.

In the first iteration, set all the vertices values as ∞. At the second iteration, the path from A to B is set to 1. At the third iteration, path from A to C is updated to 3 since it is the shortest path.

At the fourth iteration, path from A to D is set to 4 , that is the total of (1+2+1) . At the fifth iteration A to E is set to 4 , that is the direct path.

At the sixth iteration, A to F is set to 8 , that is the direct path. At the seventh iteration, A to F is set to 7 , since it is comparatively lowest cost path.

At the nineth iteration, A to G is set to 7 at first, then it will be updated to 5 on the next iteration. At the last iteration, A to H is set to 8, and later it will be updated to 6 .

The table that shows the intermediate values is as follows,

Therefore, The table showing the intermediate distance values is obtained.

03

Step 3:Show the final shortest-path tree.

(b)

The final shortest-path tree have the shortest path with lowest distance cost is as follows,

Therefore, the above figure represents the final shortest-path tree.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91Ó°ÊÓ!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Question: Often there are multiple shortest paths between two nodes of a graph. Give a linear-time algorithm for the following task.

Input: Undirected graph G = (V , E )with unit edge lengths; nodesu,v∈V

Output: The number of distinct shortest paths from utov.

In cases where there are several different shortest paths between two nodes (and edges have varying length),the most convenient of these paths is often the one with fewest edges. Forinstance, if nodes represent cities and edge lengths represent costs of flying between cities, theremight be many ways to get from cityto city t which all have the same cost. The mostconvenientof these alternatives is the one which involves the fewest stopovers. Accordingly, for a specific starting node S , define

bestu=minimum number of edges in a shortest path from S to u .

In the example below, thebestvalues for nodes S,A,B,C,D,E,Fare 0,1,1,1,2,2,3, respectively.

Give an efficient algorithm for the following problem.

Input:Graph G=V,E; positive edge lengths le; starting node s∈V.

Output: The values of bestu should be set for all nodesu∈V

Question: Prove that for the array prev computed by Dijkstra's algorithm, the edges {u,prepu}(forall∈v)form a tree.

Shortest paths are not always unique: sometimes there are two or more different paths with the minimum possible length. Show how to solve the following problem in O((|V|+|E|)log|V|)time.

Input:An undirected graph G=(V,E);edge lengths le>0; starting vertex s∈V.

Output:A Boolean array for each node u , the entry usp[u]should be true if and only if there is a unique shortest path s to u (Note:usp[s]=true)

Section 4.5.2 describes a way of storing a complete binary tree of n nodes in an array indexed by 1, 2, K, n .

(a) Consider the node at position j of the array. Show that its parent is at position [j2]and its children are at 2 jand 2 j + 1 (if these numbers are ≤n).

(b) What the corresponding indices when a complete d-ary tree is stored in an array?

Figure 4.16 shows pseudocode for a binary heap, modeled on an exposition by R.E. Tarjan. The heap is stored as an array , which is assumed to support two constant-time operations:

  • |h|, which returns the number of elements currently in the array;
  • h-1, which returns the position of an element within the array.

The latter can always be achieved by maintaining the values of h-1as an auxiliary array.

(c) Show that themakeheapprocedure takesO(n) time when called on a set of elements. What is the worst-case input? (Hint:Start by showing that the running time is at most ∑1=1nlog(ni)).

(d) What needs to be changed to adapt this pseudocode to d-ary heaps?

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.