Q19Comprehension5 Marks22 Dec 2024
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.

Consider the below pseudocode:
```
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){
foreach l in ListV{
if(M[k][l] == 1){
tempMat[i][l] = 1
}
}
}
}
}
}
return(tempMat)
End updateMatrix
```
What will the values of p and q be at the end of execution of pseudocode given below?
newMatrix = updateMatrix(M)
p = newMatrix[2][5]
q = newMatrix[0][5]