Q10Comprehension5 Marks13 Apr 2025
Passage
Let M be an adjacency matrix of a graph G given below, where M[i][j] = 1 if there is an edge from i to j, otherwise 0. ListV represents the list of vertices of the graph G. Answer the given subquestions.

Consider the below pseudocode:
What will the values of p and q be at the end of execution of pseudocode given below?
```
newMatrix = updateMatrix(M)
p = newMatrix[0][4]
q = newMatrix[0][2]
```
```
Procedure updateMatrix(M)
tempMat = M
foreach i in ListV{
foreach j in ListV{
foreach k in ListV{
if(M[i][j] == 1 and M[j][k] == 1){
if(M[k][i] == 1){
tempMat[i][i] = 1
}
}
}
}
}
return(tempMat)
End updateMatrix
```