Given Prim's pseudocode algorithm used as voraz algorithm (Figure 1) Where (pi) are the ancestors of the vertex in question and Q are the vertices that can be considered for expansion. Find the...


Given Prim's pseudocode algorithm used as voraz algorithm (Figure 1)


Where (pi) are the ancestors of the vertex in question and Q are the vertices that can be considered for expansion. Find the minimum generation tree for the graph in Figure 2


To carry out the exercise, the data structure shown in the second Table will be used.


(First Table: PRIM data structure)





















































Vertexabcdefghi
weight0inf.inf.inf.inf.inf.inf.inf.inf.
pinullnullnullnullnullnullnullnullnull
QXXXXXXXXX

* inf. = infinity symbol


In an initial stage, the vertex a is selected and therefore we start with a weight of 0. Then, the neighbors are updated (for example, the neighbors of a are b and h). They will only be updated if the update is a lower weight than an already known one. For example, from vertex a it expands to vertex b and h leaving the table as shown below:


(Second Table: First iteration)





















































Vertexabcdefghi
weight04inf.inf.inf.inf.inf.8inf.
pinullanullnullnullnullnullanull
QX---XXXXXXX

To find the most promising one, we must go through the list of weights to find the one with the lowest weight, which in this case is from vertex b. This is marked with "---" in Q because now b is part of the solution.


What is the operational cost of the algorithm? How could it be improved? Explain for both cases.


while Q + {} do<br>u+ extractMininum(Q)<br>X + XU{(u,7[u])} // if u # r<br>foreach v E Adj[u] do<br>if (v E Q) and (w(u, v) < weight|[v]) then<br>weight (u] +- w(и, v)п[u] +- и<br>end if<br>end for<br>end while<br>return X<br>

Extracted text: while Q + {} do u+ extractMininum(Q) X + XU{(u,7[u])} // if u # r foreach v E Adj[u] do if (v E Q) and (w(u, v) < weight|[v])="" then="" weight="" (u]="" +-="" w(и,="" v)п[u]="" +-="" и="" end="" if="" end="" for="" end="" while="" return="">
8<br>7<br>b<br>d<br>4<br>2<br>9.<br>a<br>а) 11<br>i<br>4<br>14<br>e<br>6<br>8<br>7<br>10<br>h<br>f<br>1<br>2.<br>

Extracted text: 8 7 b d 4 2 9. a а) 11 i 4 14 e 6 8 7 10 h f 1 2.
Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here