Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

0 1,3,2 1 5,4 2 3 3 2 4 5 5 4,6,7 6 7 Before loop: distTo[0]=0 nodes-{0,1,2,3,4,5,6,7} Loop 1: v= distTo[ ]= edgeTo[ ]=

0

1,3,2

1

5,4

2

3

3

2

4

5

5

4,6,7

6

7

Before loop:

distTo[0]=0

nodes-{0,1,2,3,4,5,6,7}

Loop 1:

v=

distTo[ ]=

edgeTo[ ]=

distTo[ ]=

edgeTo[ ]=

distTo[ ]=

edgeTo[ ]=

nodes={ }

(a) Run Dijkstra's algorithm on this graph to compute the shortest paths between 0 and every other node. For reference, the algorithm is shown on the next page. Use the adjacency list above for the order of the nodes explored and follow the trace format shown before.

image text in transcribedimage text in transcribed

(b) Annotated the edges to show the values in edgeTo, and nodes to show the values in distTo.

Part(c) what are the nodes on path from node 0 to node 6?image text in transcribed

public class Dijkstra private Di private double Eda edgero distio: LinkedList hte public Dijkstra (Ed, gers nodes i distTo new doubl Edge G. Ol rected for (int stTolvl G.vo nodes add (v) dist Tols 0.0; while (nodes size 0 0) int v nodes for (int n First0 nodes) if To Inl dist Tolv 1) nodes remove (new Integer (v)); relax (G, v); private void relax (Edge Weighted graph G, int v) for (DirectedEdge e G. adj (v)) int w e to if(dist To [w] dist Tolyl e. weight distTo [w] stTolvl e weight edgeTolwi public double distTo (int v) f return dist Tolv public boolean hasPathTo(int v) return dist Tolvl k Double POSITIVE INFINITY. public Iterable 0; Stack Directed path for (Directed Edge e e li e null e edge Tole from ()1 path .push (e); return path

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_2

Step: 3

blur-text-image_3

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

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions

Question

2. What potential barriers would you encourage Samuel to avoid?

Answered: 1 week ago