int foo(Graph G(V,E), weight function w ):: Let Q be a minHeap for(Vv € V) { } let key[V]= min of all edge weights going out of v Q.push(v); for(V(x, z) € EX{ } } print hello; while(Q not empty) { } v=Q.ExtractMin(); Print "here is (v,v)"; for(Vv € V) { }//endfor for (all x adj to v) //x---> } print (x, v); Analyze the run-time line by line if the above graph is stored as adj. List in terms of V, E then make a final analysis in terms of n, given |V|=n Describe the result if the graph is dense vs sparse.

icon
Related questions
Question

Please solve the following problem. Analyze the run-time line by line if the above graph is stored as adj. List in terms of V, E then make a final analysis in terms of n, given |V|=n Describe the result if the graph is dense vs sparse. Explain solution please.

int foo(Graph G(V,E), weight function w )::
Let Q be a minHeap
for(Vv € V) {
}
let key[V]= min of all edge weights going out of v
Q.push(v);
for(V(x, z) € EX{
}
}
print hello;
while(Q not empty) {
}
v=Q.ExtractMin();
Print "here is (v,v)";
for(Vv € V)
{
}//endfor
for (all x adj to v) //x--->
}
print (x, v);
Analyze the run-time line by line if the above graph is stored as adj. List in terms of V, E then make
a final analysis in terms of n, given |V|=n Describe the result if the graph is dense vs sparse.
Transcribed Image Text:int foo(Graph G(V,E), weight function w ):: Let Q be a minHeap for(Vv € V) { } let key[V]= min of all edge weights going out of v Q.push(v); for(V(x, z) € EX{ } } print hello; while(Q not empty) { } v=Q.ExtractMin(); Print "here is (v,v)"; for(Vv € V) { }//endfor for (all x adj to v) //x---> } print (x, v); Analyze the run-time line by line if the above graph is stored as adj. List in terms of V, E then make a final analysis in terms of n, given |V|=n Describe the result if the graph is dense vs sparse.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer