📚 Edexcel A-Level Programming: Core Constructs, Algorithms and Paradigms | Edexcel A-Level 编程:核心结构、算法与范式
Programming is central to Edexcel A-Level Computer Science, especially in Topic 6: Problem Solving with Programming. This article consolidates the core constructs, data structures, algorithms and paradigms you need to master for Paper 2 and programming project tasks.
编程是 Edexcel A-Level 计算机科学的核心,尤其是主题 6:用编程解决问题。本文汇总了你需要在 Paper 2 和编程项目任务中掌握的核心结构、数据结构、算法和编程范式。
1. Computational Thinking and Problem Decomposition | 计算思维与问题分解
Computational thinking underpins every programming task. It involves abstraction, decomposition and pattern recognition. Abstraction removes unnecessary detail to focus on the key features of a problem, decomposition breaks a large problem into smaller manageable subproblems, and pattern recognition identifies similarities so that existing solutions can be reused.
计算思维支撑着所有编程任务,包括抽象、分解和模式识别。抽象去除不必要的细节,聚焦问题的关键特征;分解把大问题拆成更小的可管理子问题;模式识别则找出相似之处,使现有解决方案可以被复用。
In Edexcel assessments you often need to write pseudocode that reflects a decomposed solution. Top-down design and stepwise refinement help you move from a high-level overview to a detailed algorithm. Clearly state inputs, processes and outputs before coding.
在 Edexcel 考试中,你经常需要编写反映分解思路的伪代码。自顶向下设计和逐步求精可帮助从高层概览过渡到详细算法。在编写代码前,要明确说明输入、处理和输出。
2. Basic Programming Constructs: Sequence, Selection and Iteration | 基本编程结构:顺序、选择与迭代
Every imperative program is built from three core constructs: sequence, selection and iteration. Sequence means executing statements in order. Selection uses IF, ELSE IF and CASE/SWITCH to choose between branches. Iteration uses WHILE, REPEAT…UNTIL and FOR loops to repeat code.
每个命令式程序都由顺序、选择和迭代三种核心结构组成。顺序指按次序执行语句;选择用 IF、ELSE IF 和 CASE/SWITCH 在不同分支中做决策;迭代用 WHILE、REPEAT…UNTIL 和 FOR 循环重复执行代码。
Selection can be nested, but nested IF statements should be kept readable. Indefinite iteration repeats until a condition changes, while definite iteration repeats a known number of times. Edexcel pseudocode uses constructs such as IF…THEN…ENDIF and WHILE…DO…ENDWHILE.
选择可以嵌套,但嵌套 IF 语句应保持可读性。不定次迭代一直重复直到条件改变,定次迭代按已知次数重复。Edexcel 伪代码使用 IF…THEN…ENDIF、WHILE…DO…ENDWHILE 等结构。
3. Data Types, Variables and Operators | 数据类型、变量与运算符
Variables must be declared with appropriate data types: Integer, Real, Boolean, Char and String. Constants are fixed values that cannot change during execution. Operators include arithmetic (+ – * / mod div), comparison (= ≠ < > ≤ ≥), and logical (AND, OR, NOT).
变量必须用合适的数据类型声明:整型、实型、布尔型、字符型和字符串型。常量是执行期间不能改变的固定值。运算符包括算术(+ – * / mod div)、比较(= ≠ < > ≤ ≥)和逻辑(AND、OR、NOT)。
Type mismatches and integer division can cause errors. In pseudocode, the assignment operator is usually ← or =. Make sure the data type of a variable matches the value it stores, especially when converting between strings and numbers.
类型不匹配和整数除法可能引发错误。在伪代码中,赋值运算符通常写作 ← 或 =。必须确保变量的数据类型与它存储的值匹配,特别是在字符串与数字之间转换时。
4. Functions, Procedures and Parameter Passing | 函数、过程与参数传递
A procedure performs a task, whereas a function performs a task and returns a value. Both can accept parameters. Parameters may be passed by value or by reference; by value copies the argument, while by reference passes its address so changes affect the original variable.
过程执行一个任务,函数执行任务并返回一个值。两者都可以接收参数。参数传递可以按值或按引用:按值传递复制实参,按引用传递则传递地址,因此修改会影响原始变量。
Local variables exist only inside a subprogram; global variables can be accessed anywhere, but excessive global use makes programs harder to debug. Edexcel questions may ask you to trace parameter passing using a stack frame or table.
局部变量仅存在于子程序内部;全局变量可在任何地方访问,但过度使用全局变量会增加调试难度。Edexcel 题目可能要求你通过栈帧或表格跟踪参数传递。
5. Arrays, Lists and Records | 数组、列表与记录
Arrays store multiple values of the same data type in indexed positions. A 1D array is a list of elements; a 2D array forms rows and columns. Lists are dynamic and can grow or shrink, while arrays usually have a fixed size unless defined as dynamic.
数组在索引位置存储同类型的多个值。一维数组是一个元素列表;二维数组构成行和列。列表是动态的,可以增长或缩小;数组除非定义为动态,否则通常大小固定。
Records group related fields of possibly different types, like a student record containing a name, age and grade. Accessing an array element uses an index such as arr[0]; many languages use zero-based indexing, but pseudocode may use 1-based indexing, so check the question.
记录把可能不同类型的相关字段组合在一起,比如学生记录包含姓名、年龄和成绩。访问数组元素使用索引,如 arr[0];许多语言从 0 开始索引,但伪代码可能从 1 开始,所以要看清题目。
6. Stacks, Queues and Linked Lists | 栈、队列与链表
A stack is a Last-In-First-Out (LIFO) structure with push, pop and peek operations. A queue is First-In-First-Out (FIFO) with enqueue and dequeue. Stacks are used in recursion and backtracking; queues are used in scheduling and buffering.
栈是后进先出(LIFO)结构,支持 push、pop 和 peek 操作。队列是先进先出(FIFO)结构,支持 enqueue 和 dequeue。栈用于递归和回溯;队列用于调度和缓冲。
Linked lists store each element in a node containing data and a pointer to the next node. Unlike arrays, linked lists allow efficient insertion and deletion, but do not support random access. You should be able to draw and trace list operations.
链表把每个元素存在一个节点中,节点包含数据和指向下一节点的指针。与数组不同,链表可以高效地插入和删除,但不支持随机访问。你应该能够画出并跟踪链表操作。
7. Searching Algorithms: Linear and Binary Search | 搜索算法:线性搜索与二分搜索
Linear search checks each element in turn until the target is found or the list ends. Its worst-case time complexity is O(n). It works on unsorted data and is simple to implement.
线性搜索逐个检查每个元素,直到找到目标或列表结束。其最坏时间复杂度为 O(n)。它适用于未排序数据,实现简单。
Binary search repeatedly divides a sorted list in half. Compare the target with the middle element, then search the left or right half. Its worst-case complexity is O(log n), which is much faster for large sorted lists.
二分搜索反复把有序列表分成两半。将目标与中间元素比较,然后搜索左半或右半部分。其最坏复杂度为 O(log n),对于大型有序列表要快得多。
Linear search: O(n) | Binary search: O(log n)
8. Sorting Algorithms: Bubble, Insertion, Merge and Quick Sort | 排序算法:冒泡、插入、归并与快速排序
Bubble sort repeatedly swaps adjacent out-of-order elements, giving O(n²) in average and worst cases. Insertion sort builds a sorted portion by inserting each next element into its correct position; it is efficient for nearly sorted data.
冒泡排序反复交换相邻的乱序元素,平均和最坏情况为 O(n²)。插入排序通过把每个新元素插入到正确位置来构建有序部分,对近乎有序的数据较高效。
Merge sort uses divide and conquer to split the list, sort halves recursively, and merge them. Its complexity is O(n log n) in all cases. Quick sort partitions around a pivot and also averages O(n log n), but degrades to O(n²) with poor pivot choices.
归并排序采用分治法,把列表拆开、递归排序两半再合并。其所有情况复杂度均为 O(n log n)。快速排序围绕基准分区,平均也是 O(n log n),但基准选择不好会退化到 O(n²)。
Merge sort: O(n log n) | Quick sort average: O(n log n) | Bubble sort: O(n²)
9. Recursion and Iteration | 递归与迭代
Recursion is a technique where a function calls itself with a smaller or simpler input. Each recursive call must have a base case to stop, otherwise stack overflow occurs. A classic example is factorial: factorial(n) = n × factorial(n-1), with factorial(1) = 1.
递归是一种函数用更小或更简单的输入调用自身的技术。每次递归调用必须有停止的基本情况,否则会出现栈溢出。经典例子是阶乘:factorial(n) = n × factorial(n-1),且 factorial(1) = 1。
Recursion mirrors mathematical definitions and is elegant for tree-like problems, but it can use more memory because each call is added to the call stack. Iteration is often more memory-efficient. Edexcel may ask you to convert between recursion and iteration.
递归镜像数学定义,适合树形问题,但由于每次调用都会加入调用栈,可能占用更多内存。迭代通常更节省内存。Edexcel 可能要求你在递归和迭代之间转换。
factorial(n) = n × factorial(n-1), factorial(1) = 1
10. Object-Oriented Programming: Encapsulation, Inheritance, Polymorphism | 面向对象编程:封装、继承与多态
Object-oriented programming (OOP) organizes code into classes and objects. A class is a template; an object is an instance. OOP promotes encapsulation, inheritance and polymorphism. Encapsulation hides internal data by marking attributes private and providing public methods.
面向对象编程(OOP)将代码组织成类和对象。类是模板,对象是实例。OOP 促进封装、继承和多态。封装通过将属性标记为私有并提供公共方法来隐藏内部数据。
Inheritance allows a subclass to extend a superclass, reusing and overriding methods. Polymorphism means the same method name can behave differently depending on the object
Published by TutorHao | A-Level 编程 Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导