Q17.The following pseudocode is executed using the "Scores" dataset. At the end of the execution, `count` captures the number of pairs of students having either same gender or from the same city but not both. But the pseudocode may have mistakes. Identify all such mistakes (if any). Assume that all statements not listed in the options below are free of errors.
```
count = 0
while(Table 1 has more rows){
Read the first row X in Table 1
Move X to Table 2
while(Table 1 has more rows){
Read the first row Y in Table 1
Move Y to Table 3
count = count + findPair(X, Y)
}
Move all rows from Table 3 to Table 1
}
Procedure findPair(X, Y)
A = False, B = True
if(X.Gender == Y.Gender){
A = True
}
if(X.CityTown == Y.CityTown){
B = True
}
if((A and not B) and (not A and B)){
return(1)
}
return(0)
End findPair
```
Save
Check
Details
Q17
25 Feb 2024
Q17.The following pseudocode is executed using the "Scores" dataset. At the end of the execution, `count` captures the number of pairs of students having either same gender or from the same city but not both. But the pseudocode may have mistakes. Identify all such mistakes (if any). Assume that all statements not listed in the options below are free of errors.
```
count = 0
while(Table 1 has more rows){
Read the first row X in Table 1
Move X to Table 2
while(Table 1 has more rows){
Read the first row Y in Table 1
Move Y to Table 3
count = count + findPair(X, Y)
}
Move all rows from Table 3 to Table 1
}
Procedure findPair(X, Y)
A = False, B = True
if(X.Gender == Y.Gender){
A = True
}
if(X.CityTown == Y.CityTown){
B = True
}
if((A and not B) and (not A and B)){
return(1)
}
return(0)
End findPair
```