Programming Constructs, Data Structures and Problem Solving for Edexcel A-Level | Edexcel A-Level 编程结构、数据结构与问题求解

📚 Programming Constructs, Data Structures and Problem Solving for Edexcel A-Level | Edexcel A-Level 编程结构、数据结构与问题求解

This revision guide covers the core programming knowledge that Edexcel A-Level Computer Science candidates need to master, from control flow and data structures to recursion, object-oriented ideas and exam technique. It is designed to help you read, trace and write pseudocode confidently under timed conditions.

本复习指南涵盖 Edexcel A-Level 计算机科学考生需要掌握的核心编程知识,包括控制流、数据结构、递归、面向对象思想以及考试技巧。它旨在帮助你在限时条件下自信地阅读、跟踪和编写伪代码。


1. Programming Paradigms and Exam Expectations | 编程范式与考试要求

Edexcel A-Level programming questions test your ability to read, trace and write structured pseudocode in a style close to Python. You are expected to understand procedural programming, especially sequence, selection and iteration, as well as more advanced object-oriented ideas such as classes and inheritance.

Edexcel A-Level 编程题目要求你能够阅读、跟踪并编写接近 Python 风格的结构化伪代码。考试要求你理解过程式编程,特别是顺序、选择和迭代,同时也要掌握类、继承等更高级的面向对象思想。

  • Procedural programming: code is organised into procedures and functions.
    过程式编程:代码被组织为过程和函数。
  • Object-oriented programming: code is organised around classes and objects.
    面向对象编程:代码围绕类和对象进行组织。
  • Exam pseudocode: Edexcel does not require a specific programming language, but your syntax must be consistent and unambiguous.
    考试伪代码:Edexcel 不要求使用特定编程语言,但语法必须一致且无歧义。

2. Sequence, Selection and Iteration | 顺序、选择与迭代

The three fundamental control structures are sequence, selection and iteration. Sequence means statements execute one after another. Selection uses IF, ELSE IF and ELSE or CASE statements to make decisions. Iteration repeats code with count-controlled FOR loops, condition-controlled WHILE loops, or post-condition REPEAT loops.

三种基本控制结构是顺序、选择和迭代。顺序表示语句逐条执行;选择使用 IF、ELSE IF、ELSE 或 CASE 语句进行判断;迭代使用计数控制的 FOR 循环、条件控制的 WHILE 循环或后条件 REPEAT 循环重复执行代码。

IF score ≥ 90 THEN grade = ‘A’
ELSE IF score ≥ 80 THEN grade = ‘B’
ELSE grade = ‘C’

In this pseudocode, the selection checks the score in descending order. A trace of any selection must test every branch, including the final ELSE case. For iteration, be clear about the loop counter, the condition, and the values at the moment the loop exits.

在这段伪代码中,选择按从高到低的顺序检查分数。跟踪任何选择结构时,必须测试每个分支,包括最后的 ELSE 情况。对于迭代,必须清楚循环计数器、条件以及循环退出瞬间的变量值。


3. Variables, Data Types, Casting and Constants | 变量、数据类型、类型转换与常量

Variables must be declared with a clear type in Edexcel pseudocode: INTEGER, REAL, BOOLEAN, CHAR and STRING are the main types. Type casting converts one type to another, such as converting a string input to an integer before arithmetic. Constants are named values that do not change during execution.

在 Edexcel 伪代码中,变量必须使用明确的数据类型声明:INTEGER、REAL、BOOLEAN、CHAR 和 STRING 是主要类型。类型转换用于把一种类型转换为另一种类型,例如在计算前把字符串输入转换为整数。常量是在执行过程中不改变的命名值。

Data type Example 中文说明
INTEGER age = 17 整数
REAL price = 9.99 实数/浮点
BOOLEAN valid = TRUE 布尔
CHAR symbol = ‘A’ 字符
STRING name = ‘Ada’ 字符串

Incorrect type handling is a common source of runtime errors. If the user enters “17” into a text field, it is stored as a string, so you must cast it to INTEGER before adding 1.

错误的数据类型处理是常见的运行时错误来源。如果用户在文本框中输入 “17”,它被存储为字符串,因此你必须在进行加 1 操作前将其转换为整数类型。


4. Arrays, Lists and 2D Structures | 数组、列表与二维结构

A one-dimensional array stores a fixed-size collection of elements of the same type, accessed by an index. In Edexcel pseudocode, indexing often starts at 0. A two-dimensional array uses row and column indices and is ideal for grids, tables and matrices.

一维数组存储固定大小的相同类型元素集合,通过下标访问。在 Edexcel 伪代码中,下标通常从 0 开始。二维数组使用行下标和列下标,非常适合表示网格、表格和矩阵。

arrNames[0] = ‘Ada’
matrix[1][2] = 7

When tracing a 2D array, first locate the row, then the column. Iterating through a 2D structure usually requires nested loops: an outer loop for rows and an inner loop for columns. Edexcel questions often present a 2D array as a grid and ask you to fill a trace table or write code to search through it.

跟踪二维数组时,应先定位行,再定位列。遍历二维结构通常需要嵌套循环:外层循环控制行,内层循环控制列。Edexcel 题目经常把二维数组表示为网格,要求你填写跟踪表或编写搜索代码。

  • Row-major order: elements are stored row by row.
    行主序:元素按行存储。
  • Column-major order: elements are stored column by column.
    列主序:元素按列存储。
  • Index out of bounds: accessing an invalid index causes an error.
    下标越界:访问无效下标会导致错误。

5. String Handling and Validation | 字符串处理与验证

String manipulation includes finding length, extracting substrings, concatenation, and conversion between upper and lower case. Validation checks whether input is reasonable before processing. Common validation techniques are presence check, range check, length check, format check and check digit.

字符串处理包括求长度、提取子串、拼接以及大小写转换。验证在处理输入之前检查数据是否合理。常见验证技术有存在检查、范围检查、长度检查、格式检查和校验位。

  • Presence check: ensures a field is not empty.
    存在检查:确保字段不为空。
  • Range check: ensures a value falls between a minimum and maximum.
    范围检查:确保值在最小值和最大值之间。
  • Length check: ensures a string has the expected number of characters.
    长度检查:确保字符串具有预期字符数。
  • Format check: ensures data follows a pattern, such as XX999.
    格式检查:确保数据遵循模式,如 XX999。
  • Check digit: uses an extra digit to detect input errors in codes.
    校验位:使用额外数字检测代码中的输入错误。

String handling questions often ask you to extract initials, count characters, or compare substrings. Always state whether indexing starts at 0 or 1 in your pseudocode.

字符串处理题目经常要求你提取首字母、统计字符或比较子串。在你的伪代码中,必须始终说明下标是从 0 还是 1 开始。


6. Subprograms: Procedures, Functions and Parameter Passing | 子程序:过程、函数与参数传递

A procedure performs a task without returning a value, while a function returns exactly one value. Parameters can be passed by value or by reference; by value copies the data, but by reference allows changes to affect the original variable. Local variables exist only inside the subroutine, while global variables are visible throughout the program.

过程执行任务但不返回值,而函数恰好返回一个值。参数可以按值传递或按引用传递;按值传递会复制数据,而按引用传递允许函数内部修改原变量。局部变量仅存在于子程序内部,而全局变量在整个程序中可见。

FUNCTION Add(a, b)
RETURN a + b
ENDFUNCTION

Edexcel expects you to identify whether a parameter is passed by value or by reference. In a trace table, a by value parameter gets its own copy, so changes inside the subroutine do not alter the original argument. A by reference parameter points to the same memory location, so changes do propagate back.

Edexcel 要求你能够识别参数是按值传递还是按引用传递。在跟踪表中,按值传递的参数获得自己的副本,因此子程序内部的变化不会改变原始实参。按引用传递的参数指向相同的内存位置,因此内部变化会传回。


7. Recursion and the Call Stack | 递归与调用栈

Recursion occurs when a subroutine calls itself. Every recursive algorithm must have a base case to stop, and a recursive case that reduces the problem toward the base case. The call stack stores return addresses and local variables for each active call.

递归发生在子程序调用自身时。每个递归算法必须有停止递归的基准情形,以及把问题规模向基准情形缩小的递归情形。调用栈为每一次活动调用存储返回地址和局部变量。

FUNCTION Factorial(n)
IF n = 0 THEN RETURN 1
ELSE RETURN n × Factorial(n – 1)
ENDIF
ENDFUNCTION

Without a base case, recursion continues until the stack overflows. In Edexcel papers, you may be asked to dry-run a recursive function for a small value such as Factorial(3). Write each stack frame on a separate row and update the return value as the stack unwinds.

没有基准情形,递归会一直进行直到栈溢出。在 Edexcel 试卷中,你可能需要对较小的数值如 Factorial(3) 手工执行递归函数。把每个栈帧单独写一行,并在栈展开时更新返回值。

  • Base case: the condition that stops recursion.
    基准情形:停止递归的条件。
  • Recursive case: the part that calls itself with a smaller problem.
    递归情形:以更小规模问题调用自身的部分。
  • Stack overflow: too many recursive calls with no base case.
    栈溢出:递归调用过多且没有基准情形。

8. Searching and Sorting Algorithms | 查找与排序算法

Linear search works on unsorted lists and checks each element in turn with O(n) time. Binary search requires a sorted list and repeatedly halves the search interval with O(log n) time. Sorting algorithms include bubble sort O(n²), merge sort O(n log n), and quick sort O(n log n) average.

线性查找适用于未

Published by TutorHao | A-Level 编程 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