📚 Pre-U CCEA Computer Science Unit Test Mock Paper Walkthrough | Pre-U CCEA 计算机科学单元测试模拟卷解析
Mock papers are one of the most effective ways to prepare for a Pre-U Unit Test in Computer Science. In this walkthrough we break down representative questions spanning data representation, logic, algorithms, data structures, object-oriented principles, databases, networking, finite state machines, recursion, and operating system concepts. Each section pairs a concise question with a step‑by‑step solution, followed by commentary that highlights exactly what examiners expect. By working through these model answers you will strengthen your problem‑solving technique and deepen your understanding of core topics specified by the CCEA syllabus.
模拟试卷是备考 Pre-U 计算机科学单元测试最有效的方式之一。本解析逐一拆解代表性题目,涵盖数据表示、逻辑、算法、数据结构、面向对象原则、数据库、网络、有限状态机、递归以及操作系统概念。每个小节将简洁的题目与逐步解答相结合,并配套评注,着重说明考官的评分期望。通过研读这些标准答案,你将提升解题技巧,并加深对 CCEA 大纲核心专题的理解。
1. Data Representation: Binary & Hexadecimal Conversion | 数据表示:二进制与十六进制转换
Question: Convert the 8‑bit binary value 10110110₂ to its decimal equivalent and then to a two‑digit hexadecimal number. Show your working.
题目:将 8 位二进制值 10110110₂ 转换为十进制等值,再转换为两位十六进制数。需展示计算过程。
A binary digit’s place value doubles from right to left. For 10110110₂ the column weights are 128, 64, 32, 16, 8, 4, 2, 1. Adding the powers where a ‘1’ appears gives 128 + 32 + 16 + 4 + 2 = 182₁₀. To reach hexadecimal, split the binary string into nibbles: 1011₂ = 11₁₀ = B₁₆ and 0110₂ = 6₁₆. Concatenating these yields B6₁₆. Marks are awarded for correct application of place value, accurate arithmetic, and proper nibble grouping.
二进制各位的权重从右至左翻倍。对于 10110110₂,列权重依次为 128、64、32、16、8、4、2、1。将出现 ‘1’ 的幂值相加:128 + 32 + 16 + 4 + 2 = 182₁₀。转换为十六进制时,将二进制串拆分为半字节:1011₂ = 11₁₀ = B₁₆,0110₂ = 6₁₆。拼接后得到 B6₁₆。评分点包括正确应用位权、精确计算以及恰当的半字节分组。
2. Logic Gates: XOR from NAND & Truth Table | 逻辑门:用与非门构造异或门及真值表
Question: Demonstrate that the XOR function can be built using only NAND gates. Draw the gate arrangement and present the truth table that confirms the final output matches A XOR B.
题目:证明异或函数可以仅由与非门构造。画出门电路并给出真值表,验证最终输出与 A XOR B 一致。
| A | B | A NAND B | A NAND (A NAND B) | B NAND (A NAND B) | Final NAND | A XOR B |
|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 0 | 0 |
The classic NAND‑only XOR construction uses four NAND gates. First, compute P = A NAND B. Second, produce Q = A NAND P and R = B NAND P. Finally, the XOR output is Q NAND R. The truth table proves that the sequence faithfully reproduces the XOR function – output is 1 only when A and B differ. Examiners look for the correct boolean identities and the systematic completion of rows.
经典的纯与非门异或结构使用四个与非门。首先计算 P = A NAND B。然后生成 Q = A NAND P 以及 R = B NAND P。最后,异或输出为 Q NAND R。真值表证明该序列忠实地再现了异或功能——只有当 A 与 B 不同时输出才为 1。考官注重正确的布尔恒等式以及完整的真值表逐行推演。
3. Sorting Algorithms: Time Complexity Comparison | 排序算法:时间复杂度对比
Question: Compare the average and worst‑case time complexity of bubble sort, insertion sort, and merge sort. Under what circumstances might insertion sort outperform merge sort despite having a higher theoretical bound?
题目:比较冒泡排序、插入排序和归并排序的平均和最差时间复杂度。在什么情况下插入排序虽然理论界限更高,其实际表现却能优于归并排序?
Algorithmic efficiency is measured using Big‑O notation on the number of comparisons and swaps. The following table summarises standard complexities:
算法效率通过比较和交换次数的 Big‑O 标记来衡量。下表汇总了标准复杂度:
| Algorithm | Average Case | Worst Case | Space |
|---|---|---|---|
| Bubble Sort | O(n²) | O(n²) | O(1) |
| Insertion Sort | O(n²) | O(n²) | O(1) |
| Merge Sort | O(n log n) | O(n log n) | O(n) |
Insertion sort excels on small datasets and on lists that are already nearly sorted, where it can approach O(n) because each element is compared only a few times. Merge sort’s divide‑and‑conquer approach incurs overhead from recursive calls and the need for auxiliary arrays, so for n below about 20, insertion sort often runs faster in practice. In an exam answer you should mention adaptive behaviour and constant factors hidden by asymptotic notation.
插入排序在小数据集和几乎有序的列表上表现出色,此时可趋近 O(n),因为每个元素仅需比较少数几次。归并排序的分治策略带来递归调用与辅助数组的开销,因此当 n 约小于 20 时,插入排序常常在实际运行中更快。在答卷中应提及自适应特性以及渐近标记所隐藏的常数因子。
4. Abstract Data Types: Stack Operations & Trace | 抽象数据类型:栈操作与追踪
Question: An empty stack is subjected to the following sequence: push(5), push(8), pop(), push(3), push(2), pop(), push(7), pop(), pop(). Show the stack contents after each operation and state the final popped value sequence.
题目:对一个空栈执行如下序列:push(5)、push(8)、pop()、push(3)、push(2)、pop()、push(7)、pop()、pop()。展示每次操作后的栈内容,并说出最终弹出的值序列。
We imagine a Last‑In‑First‑Out (LIFO) structure. After each step the top is on the right in the representation below:
我们想象一个后进先出 (LIFO) 结构。下表中的表示法里,栈顶在右侧:
| Operation | Stack Contents | Popped Value |
|---|---|---|
| push(5) | [5] | – |
| push(8) | [5, 8] | – |
| pop() | [5] | 8 |
| push(3) | [5, 3] | – |
| push(2) | [5, 3, 2] | – |
| pop() | [5, 3] | 2 |
| push(7) | [5, 3, 7] | – |
| pop() | [5, 3] | 7 |
| pop() | [5] | 3 |
The sequence of popped values is 8, 2, 7, 3. For full marks you must demonstrate awareness that pop removes and returns the most recently added element, and you must keep an accurate running trace. Mistakes often occur when students forget that the stack pointer changes after each push or pop.
弹出的值序列为 8, 2, 7, 3。欲获满分,你必须表现出对 pop 移除并返回最新加入元素的理解,并准确维护运行追踪。常见错误是学生忘记每次 push 或 pop 后栈指针已经改变。
5. Object‑Oriented Programming: Encapsulation & Polymorphism | 面向对象编程:封装与多态
Question: Using a simple ‘BankAccount’ class as an example, explain how encapsulation is achieved and how polymorphic behaviour could be introduced through an ‘Account’ superclass. Include a short Java‑like pseudocode snippet.
题目:以一个简单的 ‘BankAccount’ 类为例,解释如何实现封装,以及如何通过 ‘Account’ 超类引入多态行为。请附上一段简短的类 Java 伪代码。
Encapsulation hides an object’s internal state by declaring fields private and exposing public getters and mutators that enforce validation rules. For example:
封装通过将字段声明为私有并公开带有验证规则的公有 getter 和 setter,隐藏对象的内部状态。例如:
class BankAccount {
private double balance;
public BankAccount(double opening) { balance = opening; }
public double getBalance() { return balance; }
public void deposit(double amount) { if(amount>0) balance += amount; }
}
Polymorphism is achieved when a subclass overrides a method defined in a superclass. If an abstract Account class provides the signature displayStatement(), both SavingsAccount and ChequingAccount can implement it differently. Client code that references a variable of type Account can then invoke displayStatement() without knowing the specific subclass, allowing the system to determine at runtime which version to execute. This yields more maintainable and extensible software.
多态的实现方式是子类重写超类中定义的方法。若抽象类 Account 提供了方法签名 displayStatement(),则 SavingsAccount 和 ChequingAccount 可分别以自己的方式实现。引用类型为 Account 的变量上的客户端代码随后可调用 displayStatement() 而不必知晓具体子类,系统将在运行时决定实际执行的版本,从而产生更易维护和扩展的软件。
6. Databases: SQL Query Design & Normalisation | 数据库:SQL 查询设计与规范化
Question: Given a table Students(studentID, name, tutorGroup) and a table Grades(studentID, subject, score), write an SQL query that lists the names of all students in tutorGroup ’12A’ together with their average score in ‘Computer Science’, including only those students whose average score exceeds 70. Explain why the schema is in Third Normal Form.
题目:给定表 Students(studentID, name, tutorGroup) 和 Grades(studentID, subject, score),写出 SQL 查询,列出所有属于 ‘12A’ 导师组的学生的姓名及其在 ‘Computer Science’ 科目上的平均分,仅包含平均分超 70 的学生。并解释该模式为何满足第三范式。
SELECT s.name, AVG(g.score) AS avgScore
FROM Students s
JOIN Grades g ON s.studentID = g.studentID
WHERE s.tutorGroup = ’12A’ AND g.subject = ‘Computer Science’
GROUP BY s.studentID, s.name
HAVING AVG(g.score) > 70;
The JOIN combines records using the foreign key studentID. The WHERE clause filters rows before aggregation, while HAVING filters the aggregated groups. As for Third Normal Form (3NF), the schema has no transitive dependencies: every non‑key attribute depends directly on the primary key of its table. For example, tutorGroup depends only on studentID, not on any other non‑key attribute, and score depends on the composite key (studentID, subject). Hence the design avoids update anomalies and redundancy.
JOIN 使用外键 studentID 连接记录。WHERE 子句在聚合前筛选行,HAVING 则过滤分组后的结果。对于第三范式 (3NF),该模式不存在传递依赖:每个非键属性都直接依赖于本表的主键。例如,tutorGroup 仅依赖于 studentID,而非任何其他非键属性;score 则依赖于复合键 (studentID, subject)。因此设计避免了更新异常和冗余。
7. Networking: TCP/IP Protocol Stack & Socket API | 网络:TCP/IP 协议栈与套接字 API
Question: Outline the four layers of the TCP/IP model and briefly explain which layer the Socket API operates at. How does TCP ensure reliable delivery?
题目:概述 TCP/IP 模型的四层,并简要说明套接字 API 在哪一层运作。TCP 如何确保可靠交付?
- Application Layer – protocols such as HTTP, SMTP, FTP; data is structured for the application.
- Transport Layer – TCP/UDP; responsible for process‑to‑process communication, segmentation, and reassembly.
- Internet Layer – IP; handles logical addressing and routing across networks.
- Network Access Layer – Ethernet, Wi‑Fi; governs hardware addressing and physical transmission.
- 应用层 – HTTP、SMTP、FTP 等协议;为应用程序构造数据。
- 传输层 – TCP/UDP;负责进程间通信、分段和重组。
- 互连网络层 – IP;处理逻辑寻址和跨网络路由。
- 网络接入层 – 以太网、Wi‑Fi;管理硬件寻址和物理传输。
The Socket API is an interface between the Application and Transport layers. It hides the complexity of TCP/UDP by providing functions like socket(), bind(), connect(), send(), and recv(). TCP achieves reliable delivery through three‑way handshake, sequence numbers, acknowledgements, retransmission timers, and flow control using a sliding window. These mechanisms ensure data arrives error‑free, in order, and without duplication.
套接字 API 是应用层与传输层之间的接口,通过提供 socket()、bind()、connect()、send() 和 recv() 等函数隐藏 TCP/UDP 的复杂性。TCP 通过三次握手、序列号、确认应答、重传计时器以及基于滑动窗口的流量控制实现可靠交付。这些机制确保数据无差错、按序且无重复地到达。
8. Finite State Machines: Recognising Valid Binary Strings | 有限状态机:识别合法二进制字符串
Question: Design a deterministic finite state machine (FSM) that accepts binary strings containing an even number of 1s. Draw the state transition diagram and provide the transition table. Then determine whether the string ‘10110’ is accepted.
题目:设计一个确定性有限状态机 (FSM),接受包含偶数个 1 的二进制字符串。画出状态转换图并提供转换表,随后判断字符串 ‘10110’ 是否被接受。
We need two states: S0 (even number of 1s, also the start and accept state) and S1 (odd number of 1s). On input 0, the machine stays in the same state; on input 1, it toggles.
需要两个状态:S0(偶数个 1,同时为起始和接受状态)和 S1(奇数个 1)。输入为 0 时状态保持,输入为 1 时状态翻转。
| Current State | Input 0 | Input 1 |
|---|---|---|
| S0 | S0 | S1 |
| S1 | S1 | S0 |
Tracing ‘10110’: start S0 → 1→ S1 → 0→ S1 → 1→ S0 → 1→ S1 → 0→ S1 (final state S1). Because S1 is not an accept state, the string is rejected. Note that the machine counts 1s modulo 2, ignoring 0s. This simple two‑state FSM illustrates how abstract computational models can recognise regular languages. In exams, always specify the initial state and circle the accept state clearly.
追踪 ‘10110’:起始 S0 → 1→ S1 → 0→ S1 → 1→ S0 → 1→ S1 → 0→ S1(最终状态 S1)。因 S1 并非接受状态,该字符串被拒绝。注意机器以模 2 方式计 1 的个数,忽略 0。这个简单的两状态 FSM 展示了抽象计算模型如何识别正则语言。考试中务必明确指定起始状态并清楚地圈出接受状态。
9. Recursion: Factorial Implementation & Call Stack Behaviour | 递归:阶乘实现与调用栈行为
Question: Write a recursive function that computes the factorial of a non‑negative integer n. Explain how the call stack evolves for factorial(4), and discuss one disadvantage of recursion compared with an iterative solution.
题目:编写一个递归函数,计算非负整数 n 的阶乘。解释 factorial(4) 的调用栈如何演化,并讨论递归相比迭代方案的一个缺点。
function factorial(n):
if n ≤ 1 return 1
else return n * factorial(n-1)
For factorial(4), calls stack as follows: factorial(4) → 4 * factorial(3) → 3 * factorial(2) → 2 * factorial(1) → returns 1. Then these frames unwind, multiplying results – 2*1=2, 3*2=6, 4*6=24. Each call consumes stack memory for parameters, return address, and local variables. Deep recursion therefore risks a stack overflow error. Iteration avoids this by reusing a single loop variable, giving O(1) additional space, which is a significant advantage when n is large. Understanding the trade‑off is essential for Pre‑U candidates.
对于 factorial(4),调用栈依次为:factorial(4) → 4 * factorial(3) → 3 * factorial(2) → 2 * factorial(1) → 返回 1。随后这些帧逐层解开并相乘——2*1=2, 3*2=6, 4*6=24。每次调用都需
Published by TutorHao | Pre-U Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply