Q6Single correct6 Marks13 Apr 2025
Consider a graph generated from the "Scores" table that is represented by a matrix B. Each node in the graph corresponds to a student from the table. SeqNo is used to label the nodes in the graph. There is an edge between students i and j, with i != j, if and only if:
```
A = {}
while(Table 1 has more rows){
Read the first row X in Table 1
A[X.SeqNo] = [X.cityTown, X.Gender]
Move X to Table 2
}
n = length(keys(A))
B = createMatrix(n, n)
foreach i in keys(A){
foreach j in keys(A){
if(i != j and isRelated(A[i], A[j])){
B[i][j] = 1
}
}
}
procedure isRelated(X, Y)
if(first(X) != first(Y) and last(X) != last(Y)){
return(true)
}
else{
return(false)
}
end isRelated
```
―――――――――――――――――――――――――――――――――――――――――――――――――――――――