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 | |
|---|---|---|
| 1Max ← 4, 9, 9, 9 across the rows of a trace table | AThe Total column shows each value instead of adding to the running total | |
| 2Found = FALSE in the last row of a search trace | BThe maximum is only replaced when a larger value is found, so it stays at 9 | |
| 3A bubble sort pass compares neighbours and swaps them if they are in the wrong order | CIF Number > Max THEN Max ← Number | |
| 4A trace for a maximum starts with Max set to the first item, then updates it | DThe search value was not in the list, so the whole list was checked without a match | |
| 5Trace of a total for 3, 5, 2 shows Total as 3, 5, 2 | EThe trace ignores that 7 is found at the second item, so Found should be TRUE | |
| 6Trace of a search for 7 in 4, 7, 9 carries on to 9 and ends with Found = FALSE | FIF List[i] > List[i + 1] THEN swap them |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
trace table — A table with a column per variable and a row per step. Use it to test an algorithm such as total, maximum, search or bubble sort by following a short list of values by hand.Max ← Num[1]
FOR I ← 2 TO 5
IF Num[I] > Max THEN Max ← Num[I]I ← 1
Found ← FALSE
WHILE I <= 5 AND Found = FALSE// Trace: Found never changes to TRUE
IF Found = FALSE THEN OUTPUT "Not found"Temp ← Num[I]
Num[I] ← Num[I + 1]
Num[I + 1] ← Temp// Num has 5 values: Num[1] to Num[5]
FOR I ← 1 TO 4
// compare Num[I] with Num[I + 1]