Standard algorithms
Introduced| English | Meaning |
|---|---|
| linear search/ˈlɪnɪə sɜːtʃ/ | Checking items in sequence until the required item is found or the list ends. |
| bubble sort/ˈbʌbl sɔːt/ | A sorting algorithm that repeatedly compares adjacent items and swaps those in the wrong order until the sequence is ordered. |
| counting/ˈkaʊntɪŋ/ | Finding a number of items or events, often by increasing a counter for each one. |
| totalling/ˈtəʊtəlɪŋ/ | Adding a sequence of values to obtain their sum. |
The classic recipes
- A few standard algorithms appear again and again.
- You must know linear search 线性查找, bubble sort 冒泡排序, and the counting 计数/totalling 求和 patterns.
- Each is short, but worth recognising instantly.
Linear search
DECLARE Found : BOOLEAN
Found ← FALSE
FOR I ← 1 TO 10
IF List[I] = SearchValue
THEN
Found ← TRUE
ENDIF
NEXT I
OUTPUT Found
- A linear search checks each item in turn, from the start, until it finds the value (or reaches the end).
- It works on any list — no sorting needed.

A flowchart for the sum algorithm, using the standard symbols (start/end, input/output, process, decision).
Standard algorithms
compare adjacent, swap if needed
Step through a bubble sort — compare neighbours and swap until everything is in order.
A linear search finds a value by:
Difficulty 1/5 · 100 coins + a small bonus on first completion today
Linear search examines items one by one until it finds the value or reaches the end.
Bubble sort
FOR I ← 0 TO 8
IF List[I] > List[I + 1]
THEN
Temp ← List[I]
List[I] ← List[I + 1]
List[I + 1] ← Temp
ENDIF
NEXT I
- A bubble sort compares each side-by-side pair and swaps them if they are out of order.
- It repeats this until no more swaps are needed — leaving the list sorted.

Bubble sort compares each side-by-side pair and swaps them if they are out of order, repeating until sorted.
A bubble sort puts a list in order by:
Difficulty 1/5 · 100 coins + a small bonus on first completion today
It swaps out-of-order neighbours and repeats passes until no swaps are needed.
Totalling, counting, max/min/average
- Totalling — keep a running total:
Total ← Total + Value. - Counting — add 1 each time something happens:
Count ← Count + 1. - Maximum/minimum — keep the largest/smallest value seen so far.
- Average — divide the total by how many values there are.
Which line adds a value to a running total?
Difficulty 1/5 · 100 coins + a small bonus on first completion today
total ← total + value accumulates a sum; count ← count + 1 counts occurrences.
Match each standard algorithm to how it works.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
These four — search, sort, total and max — are the building blocks of most exam algorithms.
Using totalling on the list [2, 4, 6, 8], what is the final total?
Difficulty 2/5 · 140 coins + a small bonus on first completion today
2 + 4 + 6 + 8 = 20.
You've got it
- linear search checks each item in turn (works on any list)
- bubble sort swaps out-of-order neighbours, repeating until sorted
- totalling (
Total ← Total + Value) and counting (Count ← Count + 1) - max/min = keep the best so far; average = total ÷ count