Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1for each s in students | ABoth records are appended without matching on the key, so the same student appears twice with duplicate keys instead of one combined record | |
| 2if s.studentId = r.studentId then | Bif found = false then append s to merged | |
| 3A record with no match in the other source is appended to the merged result instead of being dropped | CLoops through every record in the first data source so each one can be checked against the second source | |
| 4Before adding a record, check that its key is not already in the merged result, so there are no duplicate keys | Dif key not in merged then append record to merged | |
| 5for each s in students append s to merged append r to merged | EThere is no handling for records with no match, so unmatched students are lost from the merged result | |
| 6for each s in students if s.studentId = r.studentId then append combined to merged endif next s | FMatches records from the two sources on the key field |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
merge algorithm — Loops through one data source, finds the record with the matching key in the other, then combines them or appends unmatched records, avoiding duplicate keys.for each a in sourceA
for each b in sourceB
if a.id = b.id thenfound ← false
if found = false then
append b to mergedif a.id = b.id then
newRec ← combine(a, b)
append newRec to mergedfor each b in sourceB
if not exists(b.id, merged) then
append b to mergedmerged ← []
for each a in sourceA
append a to merged