📚 GCSE Maths: Algorithms Revision | GCSE 数学:算法 考点精讲
Welcome to a focused revision guide on algorithms for GCSE Maths. This article unpacks the essential skills you need: constructing flowcharts, writing pseudocode, analysing sort and search algorithms, and understanding efficiency. Each key point is presented first in English, followed immediately by its Chinese translation, so you can strengthen your subject knowledge in both languages. We also include common exam pitfalls and tips to help you avoid losing marks. Let’s turn the often abstract idea of ‘algorithm’ into a clear, step‑by‑step tool you can use with confidence in the exam.
欢迎阅读 GCSE 数学算法考点精讲。本文将梳理你需要掌握的核心技能:绘制流程图、编写伪代码、分析排序与搜索算法并理解效率。每个要点先以英文呈现,紧接着给出中文翻译,帮助你用双语巩固学科知识。文中还列出了常见考试陷阱与拿分技巧。让我们一起将“算法”这个抽象的概念,变成你在考试中能够自信运用的清晰步骤。
1. What is an Algorithm? | 什么是算法?
An algorithm is a finite sequence of well‑defined, unambiguous instructions designed to solve a specific problem or perform a computation. In GCSE Maths, algorithms appear wherever you follow a procedure: long multiplication, trial and improvement, finding the highest common factor, or even the rules for rounding numbers. The key is that every step must be precise enough for someone (or a computer) to follow without additional explanation.
算法是用于解决特定问题或执行计算的一组有限、定义明确且无歧义的指令序列。在 GCSE 数学中,凡是需要遵循固定程序的地方都会涉及算法:长乘法、试位法、求最大公因数,甚至数字舍入规则。关键在于,每一步都必须足够精确,使得他人(或计算机)无需额外解释即可执行。
2. Flowcharts – Symbols and Structure | 流程图——符号与结构
A flowchart is a visual representation of an algorithm. You must be able to recognise and use standard symbols: a rounded rectangle represents Start / End; a rectangle holds a Process (e.g. Set count = 0); a diamond indicates a Decision (yes/no question); and a parallelogram shows Input / Output. Arrows connect the symbols to show the flow of control. The flowchart must have one start point and at least one end point, and all paths must eventually reach an end.
流程图是算法的可视化表示。你必须能识别并使用标准图框:圆角矩形表示开始/结束;矩形代表处理步骤(如:设 count = 0);菱形表示判断(是/否问题);平行四边形表示输入/输出。箭头连接这些图框以表示控制流。流程图必须从一个起点开始,至少有一个终点,且所有路径最终都要到达终点。
3. Pseudocode – Writing Steps Clearly | 伪代码——清晰地书写步骤
Pseudocode is a simplified, human‑readable version of a computer program. In GCSE exams you may be asked to write pseudocode that uses common keywords: INPUT, OUTPUT, SET, IF … THEN … ELSE, FOR … NEXT, WHILE … ENDWHILE, REPEAT … UNTIL. There is no single strict syntax, but your instructions must be unambiguous. For example, to add the numbers 1 to 10 you might write:
伪代码是一种简化的、人类可读的程序描述。GCSE 考试中可能要求你写出包含常见关键字的伪代码:INPUT(输入)、OUTPUT(输出)、SET(设置)、IF … THEN … ELSE(如果…则…否则)、FOR … NEXT(循环)、WHILE … ENDWHILE(当…循环)、REPEAT … UNTIL(重复…直到)。语法不一定严格统一,但你的指令必须无歧义。例如,计算 1 到 10 的和可以写成:
SET total ← 0
FOR i ← 1 TO 10
SET total ← total + i
NEXT i
OUTPUT total
Here the arrow ← is often used to mean assignment. Many exam boards also accept an equals sign, but it is safer to adopt the arrow to avoid confusion with comparison.
此处的箭头 ← 常表示赋值。许多考试局也接受等号,但为避免与比较混淆,使用箭头更安全。
4. Common Algorithm – Finding the Maximum | 常见算法——寻找最大值
A classic exam task is to write an algorithm that finds the maximum number in a list. In pseudocode:
一道经典考题是编写一个找出列表中最大数的算法。伪代码如下:
SET max ← first item in list
FOR each number in list
IF number > max THEN
SET max ← number
END IF
NEXT number
OUTPUT max
Notice the use of a conditional (IF) inside a loop. This structure appears frequently. When tracing such an algorithm on a trace table, always update the current value of max only when a larger number is encountered.
注意循环内部使用了条件判断(IF)。这种结构非常常见。在跟踪表上跟踪此算法时,只有遇到更大的数,才更新 max 的当前值。
5. Sorting – Bubble Sort | 排序——冒泡排序
Bubble sort repeatedly steps through a list, compares adjacent items and swaps them if they are in the wrong order. This is repeated until no more swaps are needed (the list is sorted). For an unsorted list of n numbers, the worst‑case number of comparisons is roughly ½n(n–1). Bubble sort is easy to understand but inefficient for large lists.
冒泡排序反复遍历列表,比较相邻元素,如果顺序错误则交换。重复这一过程直到无需再交换(列表已排序)。对 n 个数字的未排序列表,最坏情况下比较次数大致为 ½n(n–1)。冒泡排序易于理解,但对大规模列表效率低下。
Example: Sort [5, 1, 4, 2, 8] in ascending order.
例如:将 [5, 1, 4, 2, 8] 按升序排列。
Pass 1: (5,1) swap → 1,5,4,2,8; (5,4) swap → 1,4,5,2,8; (5,2) swap → 1,4,2,5,8; (5,8) no swap. End of pass 1: [1,4,2,5,8].
第一遍: (5,1) 交换 → 1,5,4,2,8;(5,4) 交换 → 1,4,5,2,8;(5,2) 交换 → 1,4,2,5,8;(5,8) 不交换。第一遍结束:[1,4,2,5,8]。
Pass 2: (1,4) no swap; (4,2) swap → 1,2,4,5,8; (4,5) no swap; (5,8) no swap. Now the list is sorted, but the algorithm performs a third pass to confirm no swaps occur.
第二遍: (1,4) 不交换;(4,2) 交换 → 1,2,4,5,8;(4,5) 不交换;(5,8) 不交换。此时列表已排好,但算法会进行第三遍以确认没有发生交换。
6. Sorting – Insertion Sort | 排序——插入排序
Insertion sort builds the final sorted list one item at a time. It takes each element from the unsorted part and inserts it into its correct position in the sorted part by shifting larger elements to the right. It is efficient for small or partially sorted data sets. The worst‑case number of comparisons is also roughly ½n(n–1), but in practice insertion sort often outperforms bubble sort.
插入排序通过每次将一个元素从未排序部分取出,并在已排序部分通过右移比它大的元素,将其插入到正确位置来构建最终有序列表。它对小型或部分有序的数据集非常高效。最坏情况比较次数也大致为 ½n(n–1),但实际应用中插入排序常常优于冒泡排序。
Example: Sort [7, 3, 5, 1] using insertion sort.
例如:用插入排序排序 [7, 3, 5, 1]。
Start: sorted part [7], unsorted [3,5,1]. Take 3 → 7 shifts right → insert 3 before 7 → [3,7]. Next take 5 → 7 shifts right → insert 5 after 3 → [3,5,7]. Take 1 → 7,5,3 shift right → insert 1 at front → [1,3,5,7]. Trace table questions will ask you to record each insertion step.
开始:已排序部分 [7],未排序 [3,5,1]。取出 3 → 7 右移 → 将 3 插入 7 前 → [3,7]。接着取出 5 → 7 右移 → 将 5 插入 3 之后 → [3,5,7]。取出 1 → 7,5,3 依次右移 → 将 1 插在最前 → [1,3,5,7]。跟踪表类问题会要求你记录每一次插入过程。
7. Searching – Linear Search | 搜索——线性搜索
Linear search examines every element in a list one by one until the target value is found or the end of the list is reached. It works on unsorted lists and is simple to code. The worst‑case number of comparisons for a list of length n is n (target at the end or not present).
线性搜索逐个检查列表中的每一个元素,直到找到目标值或到达列表末尾。它适用于未排序的列表,并且编写简单。长度为 n 的列表,最坏情况比较次数为 n(目标在末尾或不存在)。
Trace tip: a typical trace table row for linear search will show the current index, the value at that index, and a comparison result. If you need to show an algorithm terminating early because the item is found, use a conditional statement that breaks out of the loop.
跟踪技巧:线性搜索的典型跟踪表会显示当前索引、该索引处的值以及比较结果。如果需要展示因找到目标而提前终止算法,使用能跳出循环的条件语句。
8. Searching – Binary Search | 搜索——二分搜索
Binary search is a much faster algorithm, but it requires a sorted list. It repeatedly divides the search interval in half by comparing the target with the middle element. If the target equals the middle, the search stops. If the target is smaller, the right half is discarded; if larger, the left half is discarded. Each comparison halves the remaining search space, so the maximum number of comparisons is about log₂(n).
二分搜索速度快得多,但它要求列表已排序。它通过将目标与中间元素比较,反复将搜索区间减半。若目标等于中间元素,则搜索结束。若目标较小,则舍弃右半部;若较大,则舍弃左半部。每比较一次,剩余搜索空间减半,因此最大比较次数约为 log₂(n)。
Example: I want to find 23 in the sorted list [2, 5, 8, 12, 16, 23, 38, 45].
例如:在已排序列表 [2, 5, 8, 12, 16, 23, 38, 45] 中找到 23。
Step 1: middle index (0+7)//2 = 3 → value 12. 23 > 12, so new left = 4.
第 1 步:中间索引 (0+7)//2 = 3 → 值为 12。23 > 12,因此新 left = 4。
Step 2: middle index (4+7)//2 = 5 → value 23. Found.
第 2 步:中间索引 (4+7)//2 = 5 → 值为 23。找到。
Examiners often ask for the sequence of middle elements examined and for a trace table that records the values of low, high, and mid at each step.
考官常要求写出中间元素的比较序列,或是制作跟踪表记录每一步的 low、high 和 mid 值。
9. Algorithm Efficiency – Time Complexity | 算法效率——时间复杂度
GCSE candidates are not expected to use Big O notation formally, but you should understand the idea of how the number of steps grows as the input size n increases. An algorithm that scans a list once has linear growth (steps proportional to n). A nested loop over a list produces quadratic growth (steps proportional to n²), like bubble sort. An algorithm that repeatedly halves the input, like binary search, grows logarithmically—much slower than linear growth. This conceptual understanding helps you choose the best algorithm in a given scenario.
GCSE 考生虽不必正式使用大 O 表示法,但应理解随着输入规模 n 增大,步骤数如何增长。扫描一遍列表的算法呈线性增长(步数与 n 成正比)。列表上的嵌套循环会导致平方级增长(步数与 n² 成正比),例如冒泡排序。像二分搜索那样反复将输入减半的算法,则呈对数增长——远慢于线性增长。这种概念性理解可以帮助你在给定情境下选择最佳算法。
10. Euclid’s Algorithm – Finding the HCF | 欧几里得算法——求最大公因数
Euclid’s algorithm finds the highest common factor (HCF) of two positive integers a and b by repeated division. The algorithm: While b ≠ 0, find the remainder r when a is divided by b. Then set a ← b, b ← r. When b becomes 0, a is the HCF. This is a wonderfully efficient algorithm covered in many GCSE syllabuses.
欧几里得算法通过反复取余数来求两个正整数 a 和 b 的最大公因数(HCF)。算法过程:当 b ≠ 0 时,求 a 除以 b 的余数 r。然后令 a ← b,b ← r。当 b 变为 0 时,a 即为 HCF。这是一个效率极高的算法,在许多 GCSE 教学大纲中都有涉及。
Example: HCF(48, 18).
例如:HCF(48, 18)。
48 ÷ 18 = 2 remainder 12 → a=18, b=12
18 ÷ 12 = 1 remainder 6 → a=12, b=6
12 ÷ 6 = 2 remainder 0 → a=6, b=0. HCF = 6.
You may be asked to draw the flowchart or write pseudocode for this algorithm; remember the loop condition is “b ≠ 0” and the output is the final value of a.
你可能会被要求画出该算法的流程图或编写伪代码;请记住循环条件是“b ≠ 0”,输出的是 a 的最终值。
11. Common Pitfalls and Debugging Tips | 常见陷阱与调试技巧
Off‑by‑one errors: Using wrong start or end indices in a loop (e.g. FOR i ← 0 TO n forgets that indices run 0 to n‑1). Always check the first and last iteration on a trace table.
差一错误: 循环中使用了错误的起始或结束索引(如 FOR i ← 0 TO n 忘记了索引是从 0 到 n‑1)。务必在跟踪表上检查第一次和最后一次迭代。
Infinite loops: A loop that never ends because the condition never becomes false. In a WHILE loop, ensure a variable is updated inside the loop so that the condition eventually fails. In flowcharts, verify that a decision diamond has a way to exit the loop.
无限循环: 因循环条件永远不为假而导致循环永不终止。在 WHILE 循环中,确保循环体内有变量更新,使条件最终能够不满足。在流程图中,要检查判断菱形是否提供了退出循环的路径。
Misreading trace tables: Trace table questions carry easy marks if approached methodically. Write one column per variable, and fill a new row every time any variable changes. Double‑check the order of operations inside a loop—often the conditional check happens before the variable update.
误读跟踪表: 跟踪表类题目只要按部就班就能轻松得分。每个变量占一列,每当有变量发生变化就填写新的一行。请仔细核查循环体内操作的执行顺序——通常条件检查发生在变量更新之前。
12. Exam‑Style Practice | 真题风格练习
Try this typical GCSE question: ‘A program stores a list of daily rainfall measurements (in mm). Write an algorithm, using pseudocode or a flowchart, that finds and outputs the number of dry days (rainfall = 0) and the average rainfall on wet days.’
尝试这道典型的 GCSE 考题:“一个程序存储了每日降雨量数据(单位 mm)。请用伪代码或流程图编写一个算法,找出并输出干燥天数(降雨量 = 0)以及湿天的平均降雨量。”
Solution approach: SET dryCount ← 0, wetSum ← 0, wetDays ← 0. FOR each measurement: IF measurement = 0 THEN dryCount ← dryCount + 1 ELSE wetSum ← wetSum + measurement; wetDays ← wetDays + 1. END FOR. IF wetDays > 0 THEN OUTPUT dryCount, wetSum/wetDays ELSE OUTPUT dryCount, ‘No wet days’.
解题思路:令 dryCount ← 0,wetSum ← 0,wetDays ← 0。遍历每个测量值:IF 测量值 = 0 THEN dryCount ← dryCount + 1 ELSE wetSum ← wetSum + 测量值; wetDays ← wetDays + 1。循环结束后,IF wetDays > 0 THEN 输出 dryCount, wetSum/wetDays ELSE 输出 dryCount, ‘无湿天’。
Practising mixed problems like this will build your confidence in choosing the correct control structures and handling edge cases. Remember, algorithms are just logical recipes—master the patterns and you will find them one of the most predictable parts of the exam.
练习这类综合问题能增强你选择正确控制结构并处理边界情况的信心。请记住,算法不过是逻辑食谱——掌握这些模式,你就会发现这是考试中最可预测的部分之一。
Published by TutorHao | Mathematics Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导