Question
Floyd's algorithm is applied to the directed graph of problem 1. What will be the content of array P after it finishes execution? procedure Floyd(
Floyd's algorithm is applied to the directed graph of problem 1. What will be the content of array P after it finishes execution?
procedure Floyd( var A: array[1 ..n, 1 ..n] of real; var P: array[1..n, 1..n] of integer; C: array[1..n, 1..n] of real); var i, j, k: integer; begin for i := 1 to n do for j := 1 to n do begin A[i,j] := C[i,j]; P[i,j] := 0 end; for i := 1 to n do A[i,i] := 0; for k := 1 to n do for i := 1 to n do for j := 1 to n do if A[i,k]+A[k,j]then begin A[i,j] := A[i,k]+A[k,j]; P[i,j] := k end; end;
(I solved problem 1 already, here's the question for reference)
1. Trace the execution of Dijkstra's algorithm applied to a directed graph described by the following cost matrix. Choose vertex 1 as the source C[3,2]-1, CI4,51-1, CI5,6]-1. procedure Dijkstra; begin for i :-2 to n do begin D[i] := C[Li]; P[i] := 1 end; for i-= 1 to n-1 do begin choose a vertex win V-S such that DIW] is minimum, add w to S; for each vertex vin V-S do if D[v] > D[w]+ C[w,v] then begin D[y] := D[w] + C[w,y]; end end end; 1. Trace the execution of Dijkstra's algorithm applied to a directed graph described by the following cost matrix. Choose vertex 1 as the source C[3,2]-1, CI4,51-1, CI5,6]-1. procedure Dijkstra; begin for i :-2 to n do begin D[i] := C[Li]; P[i] := 1 end; for i-= 1 to n-1 do begin choose a vertex win V-S such that DIW] is minimum, add w to S; for each vertex vin V-S do if D[v] > D[w]+ C[w,v] then begin D[y] := D[w] + C[w,y]; end end endStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started