Q66Comprehension3 Marks20 Nov 2022
Passage
Let `Z` be a row in the Words table and `D` be a dictionary. Use the procedure below for the subquestions.
```
Procedure updateDict(Z, Dict)
i = 1, x = ""
while(i <= Z.LetterCount) {
x = ith letter of Z.Word
if(not isKey(Dict, x)) {
Dict[x] = 1
}
else {
Dict[x] = Dict[x] + 1
}
i = i + 1
}
return(Dict)
End updateDict
```
Let `X.Word` and `Y.Word` be "computational" and "thinking" respectively. The following pseudocode is executed using the Words dataset and the procedure `updateDict`. At the end, what is the value of `length(keys(commonDict))`?
```
firstDict = {}, secondDict = {}, commonDict = {}
firstDict = updateDict(X, commonDict)
secondDict = updateDict(Y, commonDict)
foreach key in keys(firstDict) {
if(isKey(secondDict, key)) {
if(firstDict[key] > secondDict[key]) {
commonDict[key] = firstDict[key]
}
else {
commonDict[key] = secondDict[key]
}
}
}
```
Press Enter to check.