Q43.The following pseudocode is executed using the Olympics dataset. The variable `medalDict` should store a dictionary with player name as key mapped to another dictionary. The nested dictionary stores medal type as key mapped to a list of years in which the player won that medal. The pseudocode may have mistakes. Identify all such mistakes.
```
medalDict = {}
while(Table 1 has more rows) {
Read the first row X in Table 1
if(isKey(medalDict, X.Name)) {
if(not(isKey(medalDict[X.Name], X.Medal))) {
medalDict[X.Name][X.Medal] = medalDict[X.Name][X.Medal] ++ [X.Year]
}
else {
medalDict[X.Name][X.Medal] = [X.Year]
}
}
else {
medalDict[X.Name][X.Medal] = [X.Year]
}
Move X to Table 2
}
```
Save
Check
Details
Q43
6 Aug 2023
Q43.The following pseudocode is executed using the Olympics dataset. The variable `medalDict` should store a dictionary with player name as key mapped to another dictionary. The nested dictionary stores medal type as key mapped to a list of years in which the player won that medal. The pseudocode may have mistakes. Identify all such mistakes.
```
medalDict = {}
while(Table 1 has more rows) {
Read the first row X in Table 1
if(isKey(medalDict, X.Name)) {
if(not(isKey(medalDict[X.Name], X.Medal))) {
medalDict[X.Name][X.Medal] = medalDict[X.Name][X.Medal] ++ [X.Year]
}
else {
medalDict[X.Name][X.Medal] = [X.Year]
}
}
else {
medalDict[X.Name][X.Medal] = [X.Year]
}
Move X to Table 2
}
```