Q51.The following pseudocode is executed using the Olympics dataset. At the end of execution, `medalDict` should store a nested dictionary where each player maps to medal types, and each medal type maps to a list of years. The pseudocode may have mistakes. Identify all such mistakes, if any.
```
medalDict = {}
while(Table 1 has more rows) {
Read the first row X in Table 1
if(isKey(medalDict, X.Name)) {
if(isKey(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
Q51
2 Apr 2023
Q51.The following pseudocode is executed using the Olympics dataset. At the end of execution, `medalDict` should store a nested dictionary where each player maps to medal types, and each medal type maps to a list of years. The pseudocode may have mistakes. Identify all such mistakes, if any.
```
medalDict = {}
while(Table 1 has more rows) {
Read the first row X in Table 1
if(isKey(medalDict, X.Name)) {
if(isKey(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
}
```