Q15Comprehension5 Marks1 Sep 2024
Passage
Based on above information, answer the given subquestions.
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. Consider the procedure updateMatrix given below.
```
Procedure updateMatrix(M)
tempMat = M
foreach i in rows(M){
foreach k in columns(M){
if(tempMat[i][k] == 1){
foreach j in columns(M){
if(M[k][j] == 1){
tempMat[i][j] = 1
}
}
}
}
}
return(tempMat)
End updateMatrix
```

What will the values of p and q be at the end of execution of pseudocode given below?
newMatrix1 = updateMatrix(M)
newMatrix2 = updateMatrix(newMatrix1)
p = newMatrix2[0][3]
q = newMatrix2[3][4]