4. [15 points) Consider the following procedure (Procl(G)) whose input is an undirected graph G. Edges of G are represented b

4. [15 points) Consider the following procedure (Procl(G)) whose input is an undirected graph G. Edges of G are represented by an adjacency LIST. procedure Proci(G) 1 Q.Init(); /* Q is a priority queue implemented as a Min-heap */ 2 foreach vertex v € V(G) do foreach edge (Vi, vj) incident on vi do foreach vertex vp E V(G) do 80; foreach edge (Up, vy) incident on v, do if ( = v) then 8+8+1; end end Q.Insert(s); end 13 end 14 end What is the maximum size of the priority queue Q? Analyze the running time of this algorithm in terms of the number of vertices n = V and the number of edges m = El. (Justify your answer. Do not simply give a running time.)



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *