📚 IGCSE OCR Maths: Algorithms Essentials | IGCSE OCR 数学:算法 考点精讲
Algorithms form the backbone of computational thinking within the IGCSE OCR Mathematics syllabus. Understanding how to design, interpret, and refine step-by-step procedures is essential not only for exam success but also for nurturing logical reasoning. This guide breaks down core concepts including flowcharts, pseudocode, sorting and searching algorithms, and efficiency, all aligned with OCR assessment objectives.
算法是 IGCSE OCR 数学课程中计算思维的支柱。理解如何设计、解读和改进分步流程对于考试成功和培养逻辑推理都至关重要。本文分解了核心概念,包括流程图、伪代码、排序和搜索算法以及效率,全部对标 OCR 评估目标。
1. What is an Algorithm? | 什么是算法?
An algorithm is a precise, step-by-step set of instructions designed to perform a specific task or solve a problem. In mathematics, algorithms can range from simple recipes for arithmetic to complex procedures for sorting data. Every algorithm must have a clear start and end, defined inputs and outputs, and steps that are unambiguous and finite.
算法是一组精确的、分步骤的指令,旨在执行特定任务或解决问题。在数学中,算法可以是从简单的算术规则到复杂的数据排序程序。每个算法必须有明确的开始和结束、定义的输入和输出,以及明确且有限的步骤。
In the OCR exam, you may be asked to write your own algorithm or follow a given one. Always ensure your steps are ordered logically and that every possibility is covered. An effective algorithm is like a recipe: leave out one step, and the result may be completely wrong.
在 OCR 考试中,你可能会被要求编写自己的算法或遵循给定的算法。始终确保步骤逻辑有序,并涵盖所有可能性。有效的算法就像食谱:漏掉一步,结果就可能完全错误。
2. Algorithms in the OCR IGCSE Context | OCR IGCSE 中的算法情境
OCR embeds algorithmic thinking across topics such as number operations, sequences, and data handling. You will encounter algorithms expressed as written instructions, flowcharts, or pseudocode. Typical tasks include finding the highest common factor (HCF) using Euclid’s method, generating a sequence, or searching a list.
OCR 将算法思维融入数运算、数列和数据处理等主题中。你会遇到以文字指令、流程图或伪代码表达的算法。典型任务包括用欧几里得方法求最大公因数(HCF)、生成数列或搜索列表。
Questions often present a partially completed flowchart or a faulty pseudocode and ask you to correct it. Being able to visualise the flow of data and decision points is crucial. Practice by tracing simple algorithms by hand before attempting exam questions.
题目通常给出一张部分完成的流程图或一段有错的伪代码,要求你改正。能够直观地理解数据流向和决策点至关重要。在尝试考试问题之前,可以通过手动跟踪简单算法进行练习。
3. Flowchart Symbols and Their Meanings | 流程图符号及其含义
Flowcharts use standard symbols to represent different types of steps. The oval (or rounded rectangle) indicates Start or End. A rectangle represents a process or an action, such as a calculation. A diamond shape is used for a decision, usually with Yes/No branches. Arrows show the direction of flow, and a parallelogram is used for input or output.
流程图使用标准符号表示不同类型的步骤。椭圆形(或圆角矩形)表示开始或结束。矩形代表过程或动作,如计算。菱形用于决策,通常带有是/否分支。箭头表示流向,平行四边形用于输入或输出。
| Symbol | 符号 | Name | 名称 | Purpose | 用途 |
|---|---|---|
| ⭕ Oval | Start/End | 开始/结束 | Marks the entry or exit point | 标记入口或出口 |
| ▭ Rectangle | Process | 过程 | Carries out a calculation or assignment | 执行计算或赋值 |
| ◇ Diamond | Decision | 决策 | Yes/No question that determines path | 决定路径的是/否问题 |
| ▱ Parallelogram | Input/Output | 输入/输出 | Shows data entering or leaving | 显示数据输入或输出 |
| → Arrow | Flow line | 流程线 | Connects symbols and indicates order | 连接符号并指示顺序 |
When drawing flowcharts, always label your arrows clearly, especially after a decision point. ‘Yes’ and ‘No’ branches must be unambiguous. You may be asked to complete a missing operation or decision in a given flowchart, so familiarity with these symbols saves valuable time.
绘制流程图时,始终清晰标记箭头,尤其是在决策点之后。“是”和“否”分支必须明确无误。你可能需要补全给定流程图中的缺失操作或决策,因此熟悉这些符号可以节省宝贵时间。
4. Pseudocode: A Universal Language | 伪代码:通用语言
Pseudocode is a simplified, language-independent way of describing algorithms using common programming constructs like INPUT, OUTPUT, IF…THEN…ELSE, FOR loops, and WHILE loops. OCR provides a specific pseudocode style that you should practise. For instance, INPUT x, OUTPUT y, IF x > 10 THEN, and FOR i = 1 TO n are standard.
伪代码是一种简化的、与语言无关的描述算法的方式,使用常见的程序结构,如 INPUT、OUTPUT、IF…THEN…ELSE、FOR 循环和 WHILE 循环。OCR 提供了特定的伪代码风格,你应该练习。例如,INPUT x, OUTPUT y, IF x > 10 THEN 和 FOR i = 1 TO n 是标准形式。
An important rule is to assign values using an arrow: count ← count + 1. This means ‘count becomes count + 1’. Avoid using equals signs for assignment because equals usually means comparison in mathematics. Always use indentation to show the body of a loop or conditional statement.
一个重要规则是使用箭头赋值:count ← count + 1。这表示“count 变为 count + 1”。避免用等号赋值,因为在数学中等号通常表示比较。务必使用缩进来显示循环体或条件语句的主体。
5. Tracing an Algorithm by Hand | 手动跟踪算法
Tracing means stepping through an algorithm line by line, keeping track of variable values at each stage. In the exam, trace tables are often provided with columns for each variable and output. You fill them in as you simulate the algorithm. This technique is invaluable for debugging and understanding logic.
跟踪意味着逐行执行算法,记录每个阶段变量的值。考试中通常提供跟踪表,列为各个变量和输出。你在模拟算法时填入数值。这种技术对于调试和理解逻辑非常宝贵。
For example, consider an algorithm that initialises total ← 0 and FOR i = 1 TO 3 with total ← total + i. The trace would show i taking values 1, 2, 3 and total becoming 1, 3, 6. Practice creating a trace table on paper before looking at the answer to sharpen your exam technique.
例如,考虑一个初始化 total ← 0 和 FOR i = 1 TO 3 且 total ← total + i 的算法。跟踪会显示 i 取值为 1,2,3,total 变为 1,3,6。练习在纸上建跟踪表,再核对答案,以磨炼考试技巧。
6. Bubble Sort Algorithm | 冒泡排序算法
Bubble sort is one of the simplest sorting algorithms. It repeatedly steps through a list, compares adjacent elements, and swaps them if they are in the wrong order. After each pass, the largest unsorted element ‘bubbles’ to its correct position at the end. The process repeats until no swaps are needed.
冒泡排序是最简单的排序算法之一。它重复遍历列表,比较相邻元素,若顺序错误则交换它们。每一趟之后,最大的未排序元素“冒泡”到末尾的正确位置。过程重复直到不需要交换为止。
Pseudocode for bubble sort involves a nested loop: an outer loop controlling the number of passes, and an inner loop comparing each pair. For a list with n items, a maximum of n−1 passes is needed. In OCR, you may be asked to complete a sorting trace or identify the state of a list after a certain number of passes.
冒泡排序的伪代码包含嵌套循环:外循环控制趟数,内循环比较每对元素。对于有 n 个项的列表,最多需要 n−1 趟。在 OCR 中,你可能需要完成排序跟踪,或识别经过一定趟数后的列表状态。
7. Linear Search vs Binary Search | 线性搜索与二分搜索
A linear search checks each item in a list one by one until the target is found or the list ends. It works on any list, sorted or unsorted, but can be slow for large datasets. Its worst-case scenario is when the target is at the end or not present, requiring n comparisons.
线性搜索逐个检查列表中的每一项,直到找到目标或列表结束。它适用于任何列表,无论排序与否,但对于大数据集可能较慢。最坏情况是目标在末尾或不存在,需要 n 次比较。
Binary search, on the other hand, repeatedly divides a sorted list in half to locate a target. It compares the target with the middle element: if it matches, the search ends; if the target is smaller, it continues on the left half; if larger, on the right half. This dramatically reduces the number of comparisons to about log₂n.
另一方面,二分搜索通过反复将有序列表对半分来定位目标。它将目标与中间元素比较:若匹配则搜索结束;若目标较小则继续在左半部分;若较大则在右半部分。这显著将比较次数减少到约 log₂n 次。
OCR expects you to be able to apply both methods and understand their efficiency differences. Typical question: ‘Give the number of comparisons needed to find 18 in the list [2, 5, 9, 13, 18, 22] using binary search.’ Trace it to find the answer is 3.
OCR 期望你能应用两种方法并理解其效率差异。典型问题:“使用二分搜索在列表 [2, 5, 9, 13, 18, 22] 中查找 18 需要多少次比较?”跟踪可得出答案为 3。
8. Finding the Highest Common Factor (Euclid’s Algorithm) | 求最大公因数(欧几里得算法)
Euclid’s algorithm is a classic example of an iterative mathematical algorithm. To find the HCF of two numbers a and b (a > b), repeatedly replace the larger number with the remainder when divided by the smaller until the remainder is zero. The last non-zero remainder is the HCF.
欧几里得算法是迭代数学算法的经典例子。为求两个数 a 和 b(a > b)的 HCF,反复用较小数除较大数并将较大数替换为余数,直到余数为零。最后一个非零余数即为 HCF。
For instance, HCF(48, 18): 48 ÷ 18 = 2 remainder 12; then 18 ÷ 12 = 1 remainder 6; then 12 ÷ 6 = 2 remainder 0. So HCF = 6. This algorithm is often examined through a flowchart or pseudocode fragment that you must complete or trace.
例如,HCF(48, 18):48 ÷ 18 = 2 余 12;然后 18 ÷ 12 = 1 余 6;然后 12 ÷ 6 = 2 余 0。因此 HCF = 6。这种算法常以流程图或伪代码片段的形式考察,要求你补全或跟踪。
9. Algorithm Efficiency and Complexity | 算法效率与复杂度
While OCR IGCSE does not require formal Big-O notation, you are expected to understand why some algorithms are more efficient than others. Efficiency usually refers to the number of steps or comparisons an algorithm takes relative to the input size n. A linear search has ‘linear’ efficiency (roughly proportional to n), while binary search is much faster for large n because it divides the problem size in half each time.
虽然 OCR IGCSE 不要求正式的 Big-O 表示法,但你需要理解为什么某些算法比其他算法更高效。效率通常指算法相对于输入规模 n 所需的步数或比较次数。线性搜索具有“线性”效率(大致与 n 成正比),而二分搜索对于大 n 要快得多,因为它每次将问题规模减半。
Bubble sort is generally inefficient for large lists because it compares every pair repeatedly, giving roughly n² steps. Recognising these differences helps you choose the right algorithm for a given scenario, a skill tested in context-based questions.
冒泡排序对于大列表通常效率不高,因为它反复比较每对元素,大约需要 n² 步。认识到这些差异有助于你为给定场景选择合适的算法,这是在情境题中考查的技能。
10. Common Pitfalls and Exam Preparation | 常见陷阱与备考建议
Many students lose marks by confusing assignment with equality, or by forgetting to update a loop counter. When tracing, double-check that your variable values match each step exactly. If an algorithm contains a condition like IF x MOD 2 = 0, ensure you understand modulo arithmetic.
许多学生因混淆赋值与相等、或忘记更新循环计数器而失分。跟踪时,仔细核对变量的值是否与每一步完全匹配。如果算法包含类似 IF x MOD 2 = 0 的条件,确保你理解模运算。
Another common error is misreading flowchart decision diamonds: a ‘No’ branch might go left or right, so always follow the arrows carefully. Practise writing algorithms for simple tasks—like finding the smallest number in a list—to build fluency in both pseudocode and flowchart conventions.
另一个常见错误是误读流程图中的决策菱形:“否”分支可能向左或向右,因此始终仔细跟随箭头。练习为简单任务编写算法——如找出列表中的最小数字——以熟练运用伪代码和流程图规范。
Finally, make a revision sheet of all the standard flowchart symbols and pseudocode constructs. Past exam papers reveal that OCR frequently repeats question styles: tracing a given algorithm, completing a partial flowchart, and explaining why one algorithm is more suitable than another.
最后,制作一张包含所有标准流程图符号和伪代码结构的复习表。历年真题显示,OCR 经常重复如下题型:跟踪给定算法、补全部分流程图、解释为何某种算法比另一种更合适。
Published by TutorHao | Maths Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导