Computational Thinking, End Term
Let X and Y be two rows in the “Library” table. We call X and Y compatible if books in rows X and Y are either published in the same year or under the same genre but not both. Let Compatible(X, Y) be a procedure to find whether X and Y are compatible. Choose the correct implementation of the procedure Compatible.
Let **X** and **Y** be two rows in the “Library” table. We call **X** and **Y** compatible if books in rows **X** and **Y** are either published in the same year or under the same genre but not both. Let **Compatible(X, Y)** be a procedure to find whether **X** and **Y** are compatible. Choose the correct implementation of the procedure **Compatible**. 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 studyPair Based on the above data, answer the given subquestions. What will **count1** represent at the end of execution? 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 studyPair Based on the above data, answer the given subquestions. What will **count2** represent at the end of execution?