Q10Comprehension5 Marks31 Aug 2025
Passage
Consider the implementation of the following procedure getDictionary. Assume that the procedure absolute takes an integer as parameter and returns the absolute value. For example, absolute(-2) = 2 and absolute(3) = 3.
Let D be the value returned by getDictionary([5, 10, 20, 30, 20, 10, 20, 5, 15]). Answer the given subquestions based on D.
```
Procedure getDictionary(aList)
D = {}
bList = aList
while(length(bList) > 0){
b = first(bList)
bList = rest(bList)
foreach c in bList{
if(not(isKey(D, b))){
D[b] = c
}
else{
if(absolute(b - c) < absolute(b - D[b])){
D[b] = c
}
}
}
}
return(D)
End getDictionary
```
What is the value of D[20]?