Pre-U Cambridge Computer Science: Unit Test Mock Exam Analysis | Pre-U Cambridge 计算机:单元测试模拟卷解析

📚 Pre-U Cambridge Computer Science: Unit Test Mock Exam Analysis | Pre-U Cambridge 计算机:单元测试模拟卷解析

This article analyses a mock unit test for the Cambridge Pre-U Computer Science course, covering key topics from data representation to theory of computation. Each section presents a typical exam-style question and a detailed solution, helping you refine your understanding and sharpen your problem-solving skills.

本文解析一份为剑桥 Pre-U 计算机科学课程设计的单元测试模拟卷,涵盖数据表示、计算理论等关键主题。每节提供一道典型考题及详细解答,助您巩固理解并提升解题技巧。

1. Data Representation and Binary Arithmetic | 数据表示与二进制运算

Question: Convert the 8-bit two’s complement binary number 11101100 to decimal. Show your working.

题目:将 8 位二进制补码 11101100 转换为十进制,并写出计算过程。

Solution: The most significant bit is 1, indicating a negative number. To find the magnitude, invert the bits: 00010011. Add 1: 00010100. This binary value is 20 in decimal, so the original number is -20. Alternatively, calculate place values: -128 + 64 + 32 + 0 + 8 + 4 + 0 + 0 = -20.

解析:最高位为 1,表示负数。求数值时,先对各位取反得 00010011,再加 1 得 00010100,即十进制 20,因此原数为 -20。或直接按位权计算:-128 + 64 + 32 + 8 + 4 = -20。


2. Boolean Algebra and Logic Simplification | 布尔代数与逻辑化简

Question: Simplify the Boolean expression (A + B) · (A + C) using Boolean laws or a Karnaugh map.

题目:用布尔定律或卡诺图化简表达式 (A + B) · (A + C)。

Solution: Apply the distributive law: (A + B)(A + C) = A·A + A·C + B·A + B·C = A + A·C + A·B + B·C. By absorption, A + A·C = A, and A + A·B = A, so the expression reduces to A + B·C. A three-variable Karnaugh map confirms the minimal sum-of-products form A + BC.

解析:利用分配律展开得 A·A + A·C + B·A + B·C = A + A·C + A·B + B·C。再使用吸收律,A + A·C = A,A + A·B = A,因此表达式简化为 A + B·C。三变量卡诺图同样可得到最简与或式 A + BC。


3. CPU Architecture and the Instruction Cycle | CPU 体系结构与指令周期

Question: Describe the steps of the fetch-decode-execute cycle. Then, explain what happens to the Program Counter (PC) and the Instruction Register (IR) when the instruction ‘ADD #5’ (add immediate value 5 to the accumulator) is executed on a simple processor.

题目:描述取指-译码-执行周期的步骤,并说明简单处理器执行指令 ‘ADD #5’(将立即数 5 与累加器相加)时,程序计数器 PC 和指令寄存器 IR 的变化。

Answer: Fetch – the PC sends the address to memory, the instruction is read into the IR, and the PC is incremented. Decode – the control unit decodes the opcode ‘ADD’ and identifies the immediate operand. Execute – the ALU adds 5 to the accumulator, and status flags are updated. Throughout, the PC points to the next instruction, and the IR holds ‘ADD #5’ during execution.

解答:取指——PC 将地址送入存储器,指令被读入 IR,随后 PC 递增。译码——控制单元对操作码 ‘ADD’ 译码并识别立即操作数。执行——ALU 将 5 加至累加器,状态标志更新。在整个过程中,PC 指向下一条指令,执行期间 IR 保存 ‘ADD #5’。


4. Assembly Language Tracing | 汇编语言跟踪

Question: Consider the following assembly code for a simple accumulator-based machine. Assume the accumulator ACC initially contains 0. What is the final value in ACC after execution?

题目:阅读下方基于累加器的简单机器汇编代码。假设累加器 ACC 初始值为 0,执行结束后 ACC 的最终值是多少?

   LOAD #10
   STORE 0x80
   LOAD #3
   ADD 0x80
   STORE 0x81
   HALT

Solution: LOAD #10 loads immediate 10 into ACC. STORE 0x80 saves ACC (10) to memory address 0x80. LOAD #3 sets ACC to 3. ADD 0x80 adds the value at memory 0x80 (which is 10) to ACC, giving 13. STORE 0x81 stores 13, then HALT stops execution. Final ACC = 13.

解析:LOAD #10 将立即数 10 载入 ACC。STORE 0x80 将 ACC 中的 10 存入内存地址 0x80。LOAD #3 将 ACC 置为 3。ADD 0x80 把地址 0x80 中的值 10 与 ACC 相加,得到 13。随后 STORE 0x81 保存 13,HALT 停机。最终 ACC = 13。


5. Data Structures – Linked Lists | 数据结构——链表

Question: Given a singly linked list with nodes A → B → C → D, write the sequence of pointer updates required to insert a new node X between B and C.

题目:给定单链表 A → B → C → D,写出在 B 和 C 之间插入新节点 X 所需的指针更新顺序。

Solution: Create node X. Set X.next = B.next (which currently points to C). Then set B.next = X. The list becomes A → B → X → C → D. No further traversal is needed if we hold a reference to B.

解析:创建节点 X,令 X.next = B.next(当前指向 C),然后令 B.next = X。链表变为 A → B → X → C → D。如果已有对 B 的引用,则无需遍历其他节点。


6. Algorithms – Bubble Sort | 算法——冒泡排序

Question: Consider the array [5, 3, 8, 4, 2]. Show the content of the array after each pass of a bubble sort (ascending order) until it is fully sorted. How many comparisons are made in total for n = 5?

题目:对数组 [5, 3, 8, 4, 2] 进行冒泡排序(升序),写出每趟结束后的数组内容直至完全有序。5 个元素总共进行了多少次比较?

Solution: Pass 1 – compare & swap adjacent → [3, 5, 4, 2, 8] (4 comparisons). Pass 2 → [3, 4, 2, 5, 8] (3 comparisons). Pass 3 → [3, 2, 4, 5, 8] (2 comparisons). Pass 4 → [2, 3, 4, 5, 8] (1 comparison). Sorted after 4 passes. Total comparisons = 4 + 3 + 2 + 1 = 10, which is n(n−1)/2 in the worst case.

解析:第 1 趟相邻比较交换 → [3, 5, 4, 2, 8](4 次比较);第 2 趟 → [3, 4, 2, 5, 8](3 次);第 3 趟 → [3, 2, 4, 5, 8](2 次);第 4 趟 → [2, 3, 4, 5, 8](1 次)。4 趟完成排序。总比较次数 = 4+3+2+1 = 10,为最坏情况下的 n(n−1)/2。


7. Object-Oriented Programming – Polymorphism | 面向对象编程——多态

Question: Given the following Java classes, what is the output? Explain the polymorphism concept demonstrated.

题目:给出以下 Java 类,输出是什么?并解释所展现的多态概念。

class Animal {
    void speak() { System.out.println("Some sound"); }
}
class Dog extends Animal {
    void speak() { System.out.println("Bark"); }
}
public class Test {
    public static void main(String[] args) {
        Animal a = new Dog();
        a.speak();
    }
}

Solution: The output is “Bark”. Even though the reference a is declared as type Animal, the object is an instance of Dog. At runtime, Java uses dynamic method dispatch to invoke the overridden speak() method in Dog. This is an example of runtime (dynamic) polymorphism.

解析:输出为 “Bark”。尽管引用 a 的类型是 Animal,但实际对象是 Dog 的实例。运行时,Java 通过动态方法分派调用了 Dog 中重写的 speak() 方法,体现了运行时多态。


8. Databases and SQL | 数据库与 SQL

Question: Write an SQL query to retrieve the names and grades of all students in the ‘Students’ table who are older than 17, ordered by name in ascending order. The table has columns: StudentID, Name, Age, Grade.

题目:编写 SQL 查询,从 ‘Students’ 表中检索所有年龄大于 17 岁的学生的姓名和成绩,并按姓名升序排列。表结构包含:StudentID, Name, Age, Grade。

SELECT Name, Grade
FROM Students
WHERE Age > 17
ORDER BY Name ASC;

Explanation: The SELECT clause specifies the columns to return. WHERE Age > 17 filters the rows, and ORDER BY Name ASC sorts the result in ascending alphabetical order. The query returns all matching records.

解析:SELECT 子句指定返回的列,WHERE Age > 17 过滤行,ORDER BY Name ASC 按姓名升序排列。该查询返回所有符合条件的记录。


9. Networks – IP Addressing and Subnetting | 网络——IP 地址与子网划分

Question: Given the IP address 192.168.1.132 with subnet mask 255.255.255.192 (or /26), determine the network address and the broadcast address for this subnet.

题目:给定 IP 地址 192.168.1.132,子网掩码 255.255.255.192(/26

Published by TutorHao | Pre-U Computer Science Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply

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

Exit mobile version