📚 A-Level Edexcel Programming: Core Algorithms and Data Structures | A-Level Edexcel 编程:核心算法与数据结构
This revision guide covers the core programming content required for Edexcel A-Level Computer Science, from computational thinking and pseudocode to recursion, object-oriented programming, and exam technique. Use it alongside past papers and trace tables to build confidence with algorithm design and code interpretation.
本复习指南涵盖 Edexcel A-Level 计算机科学要求的核心编程内容,从计算思维与伪代码到递归、面向对象编程和考试技巧。配合历年真题和跟踪表使用,可增强算法设计与代码解读能力。
1. Computational Thinking and Pseudocode | 计算思维与伪代码
Computational thinking involves decomposition, pattern recognition, abstraction, and algorithm design. In Edexcel exams you will be expected to write pseudocode rather than a specific programming language syntax. Pseudocode should be clear, consistent, and unambiguous.
计算思维包括分解、模式识别、抽象和算法设计。Edexcel 考试要求编写伪代码而非特定编程语言语法。伪代码应清晰、一致且无歧义。
For example, a loop to sum the first 10 integers can be written as:
例如,计算前 10 个整数之和的循环可写成:
total ← 0
FOR i ← 1 TO 10
total ← total + i
ENDFOR
OUTPUT total
Always define variables, use meaningful identifiers, and indent control structures.
始终定义变量、使用有意义的标识符并缩进控制结构。
2. Variables, Data Types and Operators | 变量、数据类型与运算符
Common data types in Edexcel pseudocode include INTEGER, REAL, BOOLEAN, CHAR, and STRING. Arithmetic operators are +, −, ×, ÷, and DIV, MOD for integer division and remainder. Comparison operators include =, ≠, <, ≤, >, ≥.
Edexcel 伪代码常见数据类型包括 INTEGER、REAL、BOOLEAN、CHAR 和 STRING。算术运算符为 +、−、×、÷,DIV 和 MOD 用于整除与取余。比较运算符包括 =、≠、<、≤、>、≥。
Use ← for assignment. For example:
赋值使用 ←。例如:
x ← 10
y ← x × 2
Operator precedence follows BIDMAS, and parentheses should be used to make intent explicit.
运算符优先级遵循 BIDMAS,应使用括号明确意图。
3. Sequence, Selection and Iteration | 顺序、选择与迭代
The three building blocks of structured programming are sequence, selection, and iteration. Selection is expressed with IF…THEN…ELSE…ENDIF, and iteration with FOR, WHILE, or REPEAT…UNTIL loops.
结构化编程的三大基本结构是顺序、选择和迭代。选择结构用 IF…THEN…ELSE…ENDIF 表示,循环用 FOR、WHILE 或 REPEAT…UNTIL 表示。
A WHILE loop tests the condition before each iteration; a REPEAT loop tests it after, so the body always executes at least once.
WHILE 循环在每次迭代前测试条件;REPEAT 循环在循环体后测试,因此循环体至少执行一次。
In exams, you may be asked to convert one loop type to another or to identify the number of iterations.
考试中可能要求转换循环类型或确定迭代次数。
4. Arrays and Lists | 数组与列表
Arrays store multiple items of the same data type in indexed locations. In Edexcel pseudocode, a 1D array can be declared as ARRAY scores[0:9] OF INTEGER, and accessed with scores[3].
数组在索引位置存储同一数据类型的多个项目。在 Edexcel 伪代码中,一维数组可声明为 ARRAY scores[0:9] OF INTEGER,并通过 scores[3] 访问。
2D arrays are useful for tables and matrices, for example ARRAY grid[0:2][0:2] OF CHAR. Common operations include traversing, searching, inserting, and deleting elements.
二维数组适用于表格和矩阵,例如 ARRAY grid[0:2][0:2] OF CHAR。常见操作包括遍历、查找、插入和删除元素。
Be careful with 0-based indexing: the first element is index 0 in most pseudocode and real languages such as Python.
注意从 0 开始的索引:在大多数伪代码和真实语言(如 Python)中,第一个元素索引为 0。
5. Searching Algorithms: Linear and Binary Search | 查找算法:线性查找与二分查找
Linear search checks each element in order and works on unsorted data. Its worst-case time complexity is O(n).
线性查找按顺序检查每个元素,适用于未排序数据。最坏时间复杂度为 O(n)。
Binary search repeatedly halves a sorted array by comparing the middle element to the target. Its time complexity is O(log₂ n), so it is much faster for large sorted data sets.
二分查找通过将中间元素与目标值比较,不断将有序数组减半。时间复杂度为 O(log₂ n),因此对大型有序数据集快得多。
You should be able to trace binary search on an array such as [2, 5, 8, 12, 16, 23, 38] and state the number of comparisons.
你应能对数组 [2, 5, 8, 12, 16, 23, 38] 跟踪二分查找过程并说明比较次数。
6. Sorting Algorithms: Bubble, Insertion and Merge Sort | 排序算法:冒泡、插入与归并排序
Bubble sort repeatedly swaps adjacent elements if they are in the wrong order. After each pass, the largest remaining value bubbles to its final position. Worst-case complexity is O(n²).
冒泡排序反复交换顺序错误的相邻元素。每趟后,剩余最大值会冒泡到最终位置。最坏时间复杂度为 O(n²)。
Insertion sort builds a sorted sublist by inserting each new element into its correct place. It is efficient for small or nearly sorted lists.
插入排序通过将每个新元素插入正确位置来构建有序子列表。对小型或接近有序的列表效率很高。
Merge sort uses divide and conquer: it splits the list into halves, recursively sorts them, then merges the two sorted halves. Its time complexity is O(n log₂ n).
归并排序采用分治法:将列表分为两半,递归排序后再合并两个有序子列表。时间复杂度为 O(n log₂ n)。
Edexcel may ask you to complete a trace table or state the order of elements after each pass.
Edexcel 可能要求填写跟踪表或说明每趟后的元素顺序。
7. Recursion and the Call Stack | 递归与调用栈
Recursion is a technique where a subroutine calls itself to solve smaller subproblems. A base case is essential to stop the recursion.
递归是子程序调用自身来解决更小子问题的技术。必须有基准情形来终止递归。
For example, factorial n! can be defined recursively:
例如,阶乘 n! 可递归定义:
factorial(n):
IF n = 1 THEN RETURN 1
ELSE RETURN n × factorial(n − 1)
Each recursive call is placed on the call stack. If the base case is missing, stack overflow occurs.
每次递归调用都压入调用栈。若缺少基准情形,会发生栈溢出。
You should be able to trace a simple recursive function and draw the call stack at a given point.
你应能跟踪简单递归函数并画出某时刻的调用栈。
8. Object-Oriented Programming Concepts | 面向对象编程概念
Object-oriented programming (OOP) organises code into classes and objects. A class is a blueprint; an object is an instance with state (attributes) and behaviour (methods).
面向对象编程(OOP)将代码组织为类和对象。类是蓝图;对象是具有状态(属性)和行为(方法)的实例。
Key principles are encapsulation, inheritance, and polymorphism. Encapsulation hides internal data behind public methods; inheritance allows a subclass to reuse and extend a parent class; polymorphism lets objects respond differently to the same method call.
关键原则是封装、继承和多态。封装将内部数据隐藏在公共方法之后;继承允许子类重用和扩展父类;多态让对象对同一方法调用作出不同响应。
In pseudocode, you may define a class with a constructor, attributes, and methods, then instantiate objects using NEW.
在伪代码中,可定义包含构造函数、属性和方法的类,然后用 NEW 实例化对象。
9. File Handling and Exception Handling | 文件处理与异常处理
Programs often need to read from or write to text files. Typical operations are OPEN, READ, WRITE, and CLOSE, with modes such as READ, WRITE, and APPEND.
程序经常需要读写文本文件。典型操作为 OPEN、READ、WRITE 和 CLOSE,模式包括 READ、WRITE 和 APPEND。
For example, to read a file line by line:
例如,逐行读取文件:
OPEN “data.txt” FOR READ
WHILE NOT EOF
INPUT line
ENDWHILE
CLOSE
Exception handling uses TRY…EXCEPT…ENDTRY to catch runtime errors such as division by zero or missing files, so the program can recover gracefully.
异常处理使用 TRY…EXCEPT…ENDTRY 捕获运行时错误(如除以零或文件缺失),使程序能够优雅恢复。
Edexcel expects you to identify possible exceptions in a given scenario and suggest appropriate handling.
Edexcel 希望你在给定情景中识别可能的异常并提出适当处理。
10. Programming Paradigms and IDEs | 编程范式与集成开发环境
A programming paradigm is a style of programming. The main paradigms are procedural, object-oriented, and functional. Edexcel focuses mainly on procedural and object-oriented approaches.
编程范式是一种编程风格。主要范式包括过程式、面向对象和函数式。Edexcel 主要关注过程式和面向对象方法。
An Integrated Development Environment (IDE) provides a code editor, error diagnostics, run-time environment, and debugging tools such as breakpoints, step-through, and watch windows.
集成开发环境(IDE)提供代码编辑器、错误诊断、运行环境和调试工具,如断点、单步执行和监视窗口。
You should know how IDEs differ from simple text editors and how features such as syntax highlighting and auto-completion improve productivity.
你应了解 IDE 与简单文本编辑器的区别,以及语法高亮和自动补全等功能如何提高效率。
11. Trace Tables and Debugging | 跟踪表与调试
Trace tables are used to test an algorithm by recording variable values after each step. They are a common Edexcel assessment tool.
跟踪表通过记录每一步后的变量值来测试算法,是 Edexcel 常用的评估工具。
When completing a trace table, use one column per variable, include loop counters and condition results, and update values in sequence.
填写跟踪表时,为每个变量设一列,包括循环计数器和条件结果,并按顺序更新值。
Debugging involves identifying logic errors, runtime errors, and syntax errors. Logic errors are hardest to detect because the program runs but gives incorrect output.
调试包括识别逻辑错误、运行时错误和语法错误。逻辑错误最难检测,因为程序能运行但输出错误。
Common debugging strategies include dry-running code, inserting temporary OUTPUT statements, and using IDE breakpoints.
常见调试策略包括人工演算代码、插入临时 OUTPUT 语句和使用 IDE 断点。
12. Exam Technique for Edexcel Programming | Edexcel 编程考试技巧
In the exam, read the algorithm question carefully and underline inputs, outputs, and data structures before writing code.
考试时,仔细阅读算法题,并在编写代码前标出输入、输出和数据结构。
Always use the exact pseudocode style shown in the question, keep indentation consistent, and use comments only where they clarify the logic.
始终使用题目所示的伪代码风格,保持缩进一致,仅在能澄清逻辑处使用注释。
Check edge cases such as empty arrays, the first and last elements, and possible divisions by zero. If a question asks for efficiency, quote Big-O notation and justify the dominant term.
检查边界情况,如空数组、首尾元素和可能的除以零。若题目要求效率,请引用大 O 表示法并说明主导项。
Finally, practise coding every algorithm on paper and in Python so that you can move confidently between pseudocode and real code.
最后,在纸上和 Python 中练习每个算法,以便你能在伪代码和真实代码之间自如转换。
Published by TutorHao | Programming Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply