Q5Single correct6 Marks22 Dec 2024
The following pseudocode is executed using the "Scores" dataset. What will Z represent at the end of the execution?
D = {}
A = 0, C = 0
while(Table 1 has more rows){
Read the first row X in Table 1
A = A + X.Total
C = C + 1
if(isKey(D, X.Town/City)){
D[X.Town/City]["Total"] = D[X.Town/City]["Total"] + X.Total
D[X.Town/City]["Count"] = D[X.Town/City]["Count"] + 1
}
else{
D[X.Town/City] = {"Total": X.Total, "Count": 1}
}
Move X to table 2
}
Avg = A / C
z = 0
foreach B in keys(D){
D[B]["Average"] = D[B]["Total"] / D[B]["Count"]
if(D[B]["Average"] < Avg){
z = z + D[B]["Count"]
}
}
Topic Mapping: chapter: Week 6 │ topic: Dictionary — Applications │ subtopic: Grouping records by city and calculating group-wise averages; comparing with overall dataset average