Question 2
The following pseudocode is executed using the “Scores” dataset. Two students form a study pair if the difference of their Mathematics marks is at most 10.
count1 = studyPair(Table 1)while (Table 1 has more rows) { Read the first row X in Table 1 if (X.CityTown == "Chennai") { Move X to Table CHN } if (X.CityTown == "Bengaluru") { Move X to Table BLR } if (X.CityTown == "Vellore") { Move X to Table VLR }}count2 = studyPair(Table CHN) + studyPair(Table BLR) + studyPair(Table VLR)
Procedure studyPair(Table 1) Table T1 = Table 1 A = 0 while (Table T1 has more rows) { Read the first row X in Table T1 Move X to Table T2 while (Table T1 has more rows) { Read the first row Y in Table T1 Move Y to Table T3 if (-10 ≤ X.Mathematics - Y.Mathematics ≤ 10) { A = A + 1 } } Move all rows from Table T3 to Table T1 } return(A)End studyPairBased on the above data, answer the given subquestions.
What will count1 represent at the end of execution?
Number of study pairs
Number of pairs of study pairs
Number of students who formed study pairs
Number of study pairs from a same city