📚 Unit Test Simulation Paper Analysis | 单元测试模拟卷解析
This article provides a detailed walkthrough of a typical Year 13 CIE Computer Science unit test. Each selected question is explained with model solutions and common pitfalls, helping students consolidate core topics such as data structures, algorithms, databases, networking, and Boolean logic. The bilingual format reinforces subject terminology in both English and Chinese, ensuring clarity for international learners.
本文对一份典型的 Year 13 CIE 计算机科学单元测试进行详细解析。每题都配有模型解答与常见误区分析,帮助学生巩固数据结构、算法、数据库、网络和布尔逻辑等核心主题。中英双语讲解强化了专业术语的理解,便于国际课程学习者掌握。
1. Circular Queue – Enqueue and Dequeue | 循环队列 – 入队与出队
A circular queue of size 5 uses an array Q[0..4] and two pointers, front and rear, initialised to -1. Enqueue increments rear modulo size; if (rear+1) mod size equals front, the queue is full. Dequeue returns Q[front] and increments front modulo size. When front equals rear after dequeue, both reset to -1, indicating empty.
一个大小为5的循环队列使用数组Q[0..4]及两个指针front和rear,初始值均为-1。入队时rear按模大小递增;若(rear+1) mod size等于front,则队列满。出队返回Q[front]并将front按模递增。当出队后front等于rear,两者重置为-1,表示空队列。
A common mistake is to check fullness only by rear == size-1, ignoring the circular nature. The modulo arithmetic guarantees O(1) time for both operations, and the space complexity is O(n).
常见错误是仅用rear == size-1判断满,而忽略了循环特性。取模运算保证了两种操作的时间复杂度均为O(1),空间复杂度为O(n)。
2. Postfix Expression Evaluation with Stack | 用栈求后缀表达式的值
Given the postfix expression “5 1 2 + 4 × + 3 −”, we evaluate using a stack: push operands; when an operator is read, pop the required number of operands, apply the operator, and push the result. The final value is 18.
给定后缀表达式”5 1 2 + 4 × + 3 −”,我们使用栈求值:遇到操作数入栈;读取到运算符时,弹出所需数量的操作数,运算后将结果入栈。最终结果为18。
Step-by-step: push 5,1,2 → pop 2 and 1, push 3 → push 4 → pop 4 and 3, push 12 → pop 12 and 5, push 17 → push 3 → pop 3 and 17, push 14? Recheck: “5 1 2 + 4 × + 3 −”. After + of 1,2 → 3. Then 4 ×: 3*4=12. Then + with 5: 5+12=17. Then 3 −: 17−3=14. So correct result is 14, not 18.
逐步演示:压入5,1,2 → 弹出2和1,压入3 → 压入4 → 弹出4和3,压入12 → 弹出12和5,压入17 → 压入3 → 弹出3和17,压入14。正确结果应为14。
The technique tests algorithmic thinking and stack trace skills. Students should show all intermediate stack states in the answer.
该题型考查算法思维和栈追踪技巧。答题时必须展示所有中间栈状态。
3. Recursion – Decimal to Binary Conversion | 递归 – 十进制转二进制
Recursive procedure: def decToBin(n): if n > 1: decToBin(n//2); print(n mod 2). For n=19, the calls unfold as decToBin(19)→decToBin(9)→decToBin(4)→decToBin(2)→decToBin(1). Output: 10011.
递归过程:def decToBin(n): 若 n > 1: decToBin(n//2); 打印(n mod 2)。对于n=19,调用展开顺序为decToBin(19)→decToBin(9)→decToBin(4)→decToBin(2)→decToBin(1)。输出:10011。
Recursion uses a system stack; each call holds its local variables and return address. The depth is O(log₂ n). Iteration may be more memory-efficient but the recursive form elegantly mirrors the mathematical definition.
递归使用系统栈;每次调用保存局部变量和返回地址。深度为O(log₂ n)。迭代可能更省内存,但递归形式优美地反映了数学定义。
4. SQL Query with JOIN on Many-to-Many Relationship | 多对多关系的SQL连接查询
Tables: Student(SID, Name, Year) and Course(CID, Title). Enrollment(SID, CID) links them. To list all students taking ‘Computer Science’, we join Enrollment with Student and Course:
数据表:Student(SID, Name, Year)和Course(CID, Title),Enrollment(SID, CID)建立多对多联系。要列出所有选修’Computer Science’的学生,需连接Enrollment、Student和Course:
SELECT Name FROM Student JOIN Enrollment ON Student.SID = Enrollment.SID JOIN Course ON Enrollment.CID = Course.CID WHERE Title = ‘Computer Science’;
Common pitfalls: forgetting the second JOIN, omitting the WHERE clause, or using NATURAL JOIN incorrectly. Always specify the linking condition.
常见错误:遗漏第二次JOIN、缺少WHERE子句或误用NATURAL JOIN。务必明确连接条件。
Aggregation can be added: count the number of students per course using GROUP BY and COUNT(*).
还可加入聚合:用GROUP BY和COUNT(*)统计每门课的学生人数。
5. TCP Three-Way Handshake and Round-Trip Time | TCP三次握手与往返时延
The TCP handshake: Client sends SYN (seq=x). Server replies SYN-ACK (seq=y, ack=x+1). Client sends ACK (ack=y+1). The round-trip time (RTT) is measured from SYN to receipt of SYN-ACK. In a test scenario, if SYN is lost, the client retransmits after timeout, doubling the timeout for each attempt (exponential backoff).
TCP握手过程:客户端发送SYN(seq=x);服务器回复SYN-ACK(seq=y, ack=x+1);客户端发送ACK(ack=y+1)。往返时延(RTT)从发送SYN到收到SYN-ACK测量。在测试场景中,若SYN丢失,客户端超时后重传,每次超时时长加倍(指数退避)。
Understanding this handshake is essential for network programming and for analysing connection establishment reliability.
理解三次握手对网络编程以及分析连接建立的可靠性至关重要。
6. Karnaugh Map Simplification of a Boolean Expression | 卡诺图化简布尔表达式
Given F(A,B,C,D) = Σ(0,2,5,7,8,10,13,15). Draw a 4-variable K-map and group minterms in powers of two. The minimal sum-of-products is F = B’D’ + BD + A’C.
给定函数F(A,B,C,D)=Σ(0,2,5,7,8,10,13,15)。绘制四变量卡诺图,并按2的幂次圈定最小项。最简与或式为F = B’D’ + BD + A’C。
Students should check for possible ‘wrap-around’ adjacencies and ensure all 1s are covered with the largest possible groups. Redundant terms can be eliminated by verifying essential prime implicants.
学生应检查可能存在的’环绕’相邻性,并确保用最大可能的组覆盖所有1。通过验证必要质蕴含项可消去冗余项。
7. 8-bit Two’s Complement Binary Arithmetic | 8位二进制补码运算
Perform 45 – 73 in 8-bit two’s complement. 45 = 00101101, 73 = 01001001. Negative of 73 is 10110111 (invert and add 1). Adding: 00101101 + 10110111 = 11100100. Since the result is negative, take two’s complement to find magnitude: 00011100 = 28, so final value is −28.
用8位补码计算45 – 73。45 = 00101101,73 = 01001001。73的负数为10110111(取反加1)。相加:00101101 + 10110111 = 11100100。结果为负,再取补码求绝对值:00011100 = 28,因此结果为−28。
Overflow detection: XOR the carry into and out of the sign bit. Here, carry in=1, carry out=0, XOR=1 indicates overflow when interpreting as signed 8-bit? Actually 45−73=−28 is within [-128,127], so no overflow occurs. Check carefully: 45+(-73) = -28, valid, no overflow flag should be set.
溢出检测:将最高位的进位输入与输出做异或。此处进位输入=1,进位输出=0,异或=1,但45-73=-28在[-128,127]内,实际无溢出。这可能暴露常见误解,需根据实际数值范围判断。
8. Finite State Machine – Vending Machine Controller | 有限状态机 – 自动售货机控制器
Design an FSM for a vending machine that accepts 50p coins only, sells a can for £1.00, and gives no change. States: S0 (0p), S1 (50p). Input: coin (1=inserted). Output: vend (1=dispense). Transitions: S0 — coin=1 → S1; S1 — coin=1 → S0, vend=1. The state diagram and transition table are required in the answer.
设计一个自动售货机的FSM,仅接受50便士硬币,罐装饮料售价1英镑,不找零。状态:S0 (0便士),S1 (50便士)。输入:coin (1=投入)。输出:vend (1=出货)。转换:S0 — coin=1 → S1;S1 — coin=1 → S0, vend=1。答案需包含状态图和转换表。
This simple Moore/Mealy distinction matters: in a Mealy machine, output depends on input and state; here vend=1 only on the transition from S1 with coin=1. Students should label arcs with ‘input/output’.
需注意Moore/Mealy区别:在Mealy机中,输出取决于输入和状态;此处vend=1仅在从S1出发且coin=1的转换上触发。学生应在弧上标记’输入/输出’。
9. Legal and Ethical Issues – Software Piracy | 法律与道德议题 – 软件盗版
Discuss the consequences of software piracy for individuals and organisations. Legal risks include criminal prosecution under copyright law, fines, and imprisonment. Ethical concerns involve loss of revenue for developers, reduced incentive for innovation, and potential malware risks from unlicensed copies.
讨论软件盗版对个人和组织的影响。法律风险包括版权法下的刑事起诉、罚款和监禁。道德问题涉及开发者收入损失、创新动力下降,以及非授权副本可能带来的恶意软件风险。
Organisations face reputational damage and may be liable for employee actions if proper software asset management policies are not in place. The CIE exam often asks for balanced answers referencing both legal and ethical dimensions.
若缺乏适当的软件资产管理政策,组织将面临声誉损害,并可能对员工行为负责。CIE 考试常要求从法律和道德两个维度给出平衡的答案。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导