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 | |
|---|---|---|
| 1IF Numbers[i] > Numbers[i + 1] THEN | AIF Scores[i] < Scores[i + 1] THEN | |
| 2Temp ← Numbers[i] | BStores one of the two items safely so the pair can be swapped without losing a value | |
| 3Each pass of a bubble sort compares neighbours from the start of the list up to the last item not yet in place | COne pass only guarantees that the largest value is at the end. More passes are usually needed, so the sort is not necessarily finished. | |
| 4To sort in descending order, swap when the left item is smaller than the right item | DCompares two neighbouring items and checks whether they are in the wrong order for an ascending sort | |
| 5[5, 3, 8] after one pass becomes [3, 5, 8] and the sort is always finished | EA bubble sort can sort strings as well as numbers, because strings can be compared in alphabetical order. | |
| 6Names: Zara, Adam, Maya. Bubble sort cannot sort text, only numbers | FFOR i ← 1 TO 4 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
bubble sort — A sorting method that compares neighbouring items and swaps them if in the wrong order, repeating passes until the list is sorted. The largest value bubbles to the end each pass.IF Numbers[i] > Numbers[i + 1] THENTemp ← Numbers[i]
Numbers[i] ← Numbers[i + 1]
Numbers[i + 1] ← TempIF Numbers[i] < Numbers[i + 1] THENFOR Pass ← 1 TO 4
FOR i ← 1 TO 5 - PassIF Names[i] > Names[i + 1] THEN