📚 PDF资源导航

IGCSE Edexcel Maths: Algorithms Key Points | IGCSE Edexcel 数学:算法考点精讲

📚 IGCSE Edexcel Maths: Algorithms Key Points | IGCSE Edexcel 数学:算法考点精讲

In IGCSE Edexcel Mathematics, algorithms are an important topic that tests your logical thinking and ability to follow precise instructions. An algorithm is a finite sequence of unambiguous steps designed to perform a task or solve a problem. You will encounter algorithms represented as flowcharts, pseudocode, or written instructions. Mastering algorithm tracing and writing simple algorithms can boost your exam performance significantly.

在IGCSE Edexcel数学中,算法是考察逻辑思维和遵循精确指令能力的重要主题。算法是一组有限的、明确无误的步骤,用于执行任务或解决问题。考试中你会遇到以流程图、伪代码或书面说明形式呈现的算法。掌握算法追踪和编写简单算法能显著提高你的考试成绩。


1. What is an Algorithm in IGCSE Maths? | 什么是算法?

An algorithm is a precise, step-by-step plan for solving a mathematical problem. In the IGCSE context, algorithms must be finite (they always end), unambiguous (clear at each step), and produce correct outputs for given inputs. Typical tasks include summing numbers, sorting data, finding maximum or minimum values, counting occurrences, and generating prime numbers.

算法是解决数学问题的精确、逐步的计划。在IGCSE范畴内,算法必须具有有限性(总会结束)、明确性(每一步清晰),并且对给定输入产生正确输出。典型任务包括数字求和、数据排序、查找最大值或最小值、计数出现次数以及生成素数。

For example, a simple algorithm to add all integers from 1 to 10 could be: “Set a total to 0. While the number is not more than 10, add the number to the total and increase the number by 1.” This clear sequence guarantees the correct sum of 55.

例如,一个计算从1到10所有整数和的简单算法可以是:“将总和设为0。当数字不大于10时,将数字加到总和上,并将数字增加1。” 这个清晰的序列保证得到正确的和55。


2. Flowchart Symbols and Structure | 流程图符号与结构

Flowcharts are visual representations of algorithms using standard symbols connected by arrows. Each shape has a specific meaning, and the sequence of operations follows the flow lines. Understanding these symbols is essential for interpreting algorithm diagrams in exams.

流程图是使用标准符号并由箭头连接的算法可视化表示。每种形状都有特定含义,操作顺序沿流程线进行。理解这些符号对于在考试中解释算法图至关重要。

Symbol Shape Meaning
Ellipse / Rounded rectangle Oval Start or End of the algorithm
Rectangle Box Process / Calculation step
Parallelogram Slanted box Input or Output operation
Diamond Rhombus Decision / Condition (Yes/No)
Arrow Directed line Flow of control

Among these, the diamond-shaped decision box is crucial for creating loops and branches. For example, a flowchart to check if a number is even could: input a number, use a decision box asking “Is the number divisible by 2?”, then output “Even” if Yes, else “Odd”.

在这些符号中,菱形判断框对于创建循环和分支至关重要。例如,一个判断数字是否为偶数的流程图可以:输入一个数字,使用判断框询问“数字能否被2整除?”,如果“是”则输出“偶数”,否则输出“奇数”。


3. Pseudocode Conventions | 伪代码约定

Pseudocode is a simplified, language-independent way to describe algorithms using structured English-like statements. In Edexcel IGCSE Maths, you are expected to read and write pseudocode without worrying about strict syntax, but certain keywords are standard.

伪代码是一种简化的、与语言无关的描述算法的方式,使用结构化的类英语语句。在Edexcel IGCSE数学中,你需要读写伪代码,无需担心严格语法,但某些关键词是标准的。

Common instructions include:

常用指令包括:

SET – assigns a value to a variable, e.g. SET count = 0
INPUT / OUTPUT – handles user interaction
IF…THEN…ELSE…ENDIF – conditional branching
WHILE…DO…ENDWHILE – a pre-condition loop
FOR…TO…NEXT or FOR…NEXT – a counting loop
Often, they appear as FOR i = 1 TO 10 followed by NEXT i.

SET – 将值赋给变量,例如 SET count = 0
INPUT / OUTPUT – 处理用户交互
IF…THEN…ELSE…ENDIF – 条件分支
WHILE…DO…ENDWHILE – 前置条件循环
FOR…TO…NEXTFOR…NEXT – 计数循环
通常会出现 FOR i = 1 TO 10 紧接着 NEXT i

A typical pseudocode snippet: SET total = 0
FOR n = 1 TO 5
  INPUT num
  total = total + num
NEXT n
OUTPUT total. This reads five numbers and outputs their sum.

一段典型的伪代码:SET total = 0
FOR n = 1 TO 5
  INPUT num
  total = total + num
NEXT n
OUTPUT total。该代码读取五个数字并输出它们的和。


4. Tracing an Algorithm: Step by Step | 逐步追踪算法

Tracing means simulating the algorithm line by line and recording the value of each variable after each step. A trace table is the best tool for this. It shows how variables change, helping you verify correctness or find errors.

追踪意味着逐行模拟算法,并在每一步后记录每个变量的值。追踪表是实现这一目标的最佳工具。它展示了变量如何变化,帮助你验证正确性或查找错误。

Consider the following algorithm that sums even numbers from 2 to 8:

考虑以下算法,它对2到8之间的偶数求和:

SET sum = 0
FOR x = 2 TO 8 STEP 2
  sum = sum + x
NEXT x
OUTPUT sum

The trace table below shows the dry run:

下方的追踪表展示了模拟运行过程:

Iteration x sum (after addition)
(initial) 0
1 2 2
2 4 6
3 6 12
4 8 20

After the loop finishes, the output is 20. Tracing ensures you correctly follow the loop’s start value, step, and final condition.

循环结束后,输出为20。追踪确保你正确遵循循环的起始值、步长和结束条件。


5. Algorithm for Sum and Mean | 求和与均值的算法

One of the most common IGCSE algorithm tasks is calculating the sum and average (mean) of a list of numbers. The algorithm must initialize a running total to zero, then iterate through each value adding it to the total. Finally, the mean is total divided by the number of items.

IGCSE中最常见的算法任务之一是计算一组数字的总和与平均值。算法必须将运行总和初始化为零,然后遍历每个值并将其加到总和中。最后,平均值等于总和除以项目的个数。

Pseudocode for sum and mean of n numbers:

求n个数字的总和与均值的伪代码:

SET total = 0
FOR i = 1 TO n
  INPUT number
  total = total + number
NEXT i
SET mean = total / n
OUTPUT "Sum:", total
OUTPUT "Mean:", mean

In an exam, you may be asked to trace such an algorithm with given inputs. Always check that the loop counter runs exactly n times. A common mistake is dividing by the wrong count, for example using the final value of the loop variable instead of n.

在考试中,你可能需要根据给定输入追踪这样的算法。始终检查循环计数器是否恰好运行了n次。一个常见错误是除以了错误的计数,例如使用循环变量的最终值而不是n。


6. Finding Maximum and Minimum Values | 查找最大值与最小值

To find the largest number in a list, we can assume the first number is the maximum, then compare each subsequent number with the current maximum. If a larger number is found, it replaces the current maximum. A similar logic works for the minimum.

要找到列表中的最大数字,我们可以假设第一个数字是最大值,然后将其余每个数字与当前最大值比较。如果找到更大的数字,就替换当前最大值。类似逻辑也适用于查找最小值。

Example pseudocode for finding the maximum of five input values:

寻找五个输入值中最大值的伪代码示例:

INPUT firstNum
SET max = firstNum
FOR count = 1 TO 4
  INPUT nextNum
  IF nextNum > max THEN
    max = nextNum
  ENDIF
NEXT count
OUTPUT "Maximum is ", max

Note that we only need four more inputs because one has already been taken. Setting the first number as the initial max guarantees a valid comparison from the start.

注意,我们只需要再输入四个数字,因为已经取了一个。将第一个数字设置为初始最大值保证了从一开始就有一个有效的比较。


7. Counting Occurrences | 计数出现次数

Counting how many times a target value appears in a data set is a common algorithm. A counter variable is initialised to zero and incremented each time the target is encountered during a loop through the data.

统计目标值在数据集中出现的次数是一种常见算法。计数器变量初始化为零,并在循环遍历数据时每次遇到目标值时递增。

For instance, to count how many students scored exactly 80 marks in a test:

例如,统计有多少名学生在考试中恰好得了80分:

SET count = 0
FOR student = 1 TO 30
  INPUT mark
  IF mark = 80 THEN
    count = count + 1
  ENDIF
NEXT student
OUTPUT count

Make sure the counter is set to zero before the loop. Forgetting this initialisation is a typical mistake that would cause the algorithm to produce an unpredictable result.

确保在循环之前将计数器设置为零。忘记这一初始化是一个典型错误,会导致算法产生不可预测的结果。


8. Sorting Algorithms: Bubble Sort | 排序算法:冒泡排序

Bubble sort is a simple sorting algorithm often tested in IGCSE Edexcel Maths. It repeatedly steps through the list, compares adjacent items, and swaps them if they are in the wrong order. The largest unsorted element “bubbles” to its correct position in each pass.

冒泡排序是一种简单的排序算法,在IGCSE Edexcel数学中经常考察。它反复遍历列表,比较相邻项,如果顺序错误则交换它们。每次遍历中,最大的未排序元素就会“冒泡”到正确的位置。

Consider sorting the list [5, 3, 8, 1] in ascending order:

考虑将列表 [5, 3, 8, 1] 按升序排序:

Pass 1: Compare 5 and 3 → swap → [3,5,8,1]. Compare 5 and 8 → keep. Compare 8 and 1 → swap → [3,5,1,8]. After pass 1, the largest element 8 is in the final position.

第1趟:比较5和3 → 交换 → [3,5,8,1]。比较5和8 → 保持。比较8和1 → 交换 → [3,5,1,8]。第1趟后,最大元素8位于最终位置。

Pass 2: Compare 3 and 5 → keep. Compare 5 and 1 → swap → [3,1,5,8]. Now 5 is at its correct position.

第2趟:比较3和5 → 保持。比较5和1 → 交换 → [3,1,5,8]。现在5位于正确位置。

Pass 3: Compare 3 and 1 → swap → [1,3,5,8]. The list is sorted.

第3趟:比较3和1 → 交换 → [1,3,5,8]。列表已排序。

The number of passes required is n-1 for a list of n items. Trace tables for bubble sort algorithms often ask you to record swaps and the state of the list after each pass.

对于有n个项目的列表,需要的趟数为n-1。冒泡排序算法的追踪表通常会要求你记录交换情况以及每趟后的列表状态。


9. The Sieve of Eratosthenes for Primes | 埃拉托斯特尼筛法找素数

The Sieve of Eratosthenes is an ancient algorithm for finding all prime numbers up to any given limit n. This is explicitly listed in the Edexcel IGCSE syllabus and is often examined as a tracing exercise or by asking you to apply the steps.

埃拉托斯特尼筛法是一种古老的算法,用于找出不超过给定上限n的所有素数。该算法在Edexcel IGCSE大纲中明确列出,常以追踪练习或要求你应用步骤的形式进行考察。

The algorithm works as follows for n = 30:

对于n = 30,该算法的工作方式如下:

Step 1: Write a list of integers from 2 to 30.
Step 2: Let p = 2, the first prime. Cross out all multiples of 2 (4, 6, 8, … 30).
Step 3: Find the next number not crossed out, i.e. 3, which is prime. Cross out multiples of 3 (6, 9, 12, … ) that are not already crossed out.
Step 4: The next untouched number is 5. Cross out its multiples (10, 15, 20, 25, 30).
Step 5: Continue with the next prime 7. Cross out 14, 21, 28. Since 7 > √30, stop. All remaining numbers are primes: 2,3,5,7,11,13,17,19,23,29.

步骤1:写下从2到30的整数列表。
步骤2:令p = 2,第一个素数。划掉所有2的倍数(4,6,8,…30)。
步骤3:找到下一个未被划掉的数字,即3,它是素数。划掉尚未被划掉的3的倍数(6,9,12,…)。
步骤4:下一个未处理的数字是5。划掉它的倍数(10,15,20,25,30)。
步骤5:继续处理下一个素数7。划掉14,21,28。因为7 > √30,停止。剩下的所有数字都是素数:2,3,5,7,11,13,17,19,23,29。

In the exam, you may be given a partially completed sieve and asked to fill in the missing crossed-out numbers or identify the next prime to use.

在考试中,你可能会得到一个部分完成的筛法网格,并被要求填写缺少的划掉数字或确定下一个要使用的素数。


10. Writing Simple Algorithms | 编写简单算法

Examiners often ask you to design an algorithm to solve a specific problem. You need to express the logic clearly using pseudocode or a flowchart. The solution must handle all cases and terminate.

考官经常要求你设计一个算法来解决特定问题。你需要使用伪代码或流程图清晰地表达逻辑。解法必须能够处理所有情况并终止。

Example: Write an algorithm that outputs all factors of a positive integer n.

示例:编写一个算法,输出正整数n的所有因数。

Pseudocode solution:

伪代码解决方案:

INPUT n
FOR d = 1 TO n
  IF n mod d = 0 THEN
    OUTPUT d
  ENDIF
NEXT d

mod gives the remainder. The loop checks every integer up to n. A more efficient version could loop only to √n and output both d and n/d. However, the simple approach is acceptable at IGCSE level.

mod 给出余数。循环检查了直到n的每个整数。更高效的版本可以只循环到√n,并输出d和n/d。不过,简单的做法在IGCSE水平上是可以接受的。

When writing, always indicate start and end, initialise variables, and use clear conditions.

编写时,务必标注开始与结束,初始化变量,并使用清晰的条件。


11. Common Pitfalls and Exam Tips | 常见陷阱与考试技巧

Many marks are lost due to small, avoidable errors. Be aware of the following:

许多分数是因为小的、可避免的错误而丢失的。请注意以下几点:

Uninitialised variables:Published by TutorHao | IGCSE Mathematics Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading