Year 13 OCR Computer Science: Mock Unit Test Walkthrough | Year 13 OCR 计算机:单元测试模拟卷解析

📚 Year 13 OCR Computer Science: Mock Unit Test Walkthrough | Year 13 OCR 计算机:单元测试模拟卷解析

This article provides a detailed walkthrough of a mock unit test covering key topics from the OCR A Level Computer Science syllabus. We will examine typical exam-style questions, model answers, and examiner commentary to help Year 13 students consolidate their understanding and exam technique.

本文详细解析了一份涵盖 OCR A Level 计算机科学课程核心主题的单元测试模拟卷。我们将分析典型的考试题型、标准答案及考官点评,帮助 Year 13 学生巩固理解并提升应试技巧。

1. Processor Architecture & Assembly Language | 处理器架构与汇编语言

Question: Compare CISC and RISC processor architectures, explaining how their design philosophies affect instruction execution, pipelining, and register usage. [6 marks]

题目:比较 CISC 与 RISC 处理器架构,说明其设计理念如何影响指令执行、流水线技术和寄存器使用。[6分]

CISC (Complex Instruction Set Computer) processors employ a large set of instructions, many of which can perform multi-step operations in a single instruction. This reduces the number of instructions per program but results in variable-length instructions that are difficult to pipeline efficiently.

CISC(复杂指令集计算机)处理器使用庞大的指令集,其中许多指令可在单条指令中完成多步操作。这减少了程序的指令数,但导致指令长度不一,难以高效流水线处理。

By contrast, RISC (Reduced Instruction Set Computer) architectures use a smaller, highly optimised set of simple instructions, each typically executed in one clock cycle. Fixed-length instructions make pipelining straightforward, and compilers can generate efficient code by relying on a larger general-purpose register file.

相比之下,RISC(精简指令集计算机)架构采用精简且高度优化的小型指令集,每条指令通常在一个时钟周期内执行。固定指令长度简化了流水线设计,编译器可以依赖更多的通用寄存器生成高效代码。

Additionally, RISC designs tend to use a load-store architecture, where only load and store instructions access memory; arithmetic operations are performed on registers. This contrasts with CISC, which often allows memory operands in arithmetic instructions.

此外,RISC 设计通常采用加载-存储架构,仅加载和存储指令访问内存,算术运算在寄存器上完成。这与 CISC 形成对比,后者常常允许算术指令直接使用内存操作数。


2. Memory Management & Virtual Storage | 内存管理与虚拟存储

Question: Explain how demand paging and page replacement algorithms help manage virtual memory. Use a specific algorithm, such as LRU, to illustrate your answer. [4 marks]

题目:解释请求分页和页面置换算法如何帮助管理虚拟内存。选择一个具体算法(如 LRU)来说明你的回答。[4分]

Demand paging loads a page into main memory only when it is referenced, reducing I/O overhead and allowing processes to exceed physical memory size. When a page fault occurs, the operating system must select a page to evict using a replacement algorithm.

请求分页仅在页面被引用时才将其加载到主存,从而减少 I/O 开销并允许进程占用超过物理内存的空间。当发生缺页中断时,操作系统必须使用置换算法选择一个页面换出。

The Least Recently Used (LRU) algorithm replaces the page that has not been used for the longest time, based on the principle of temporal locality. It requires tracking page access timestamps, which can be implemented with a stack or counters, but hardware support is often needed for efficiency.

最近最少使用(LRU)算法基于时间局部性原理,替换最长时间未使用的页面。这需要跟踪页面访问时间戳,可用栈或计数器实现,但往往需要硬件支持以保证效率。


3. Data Structures: Linked Lists & Hash Tables | 数据结构:链表与哈希表

Question: Compare the efficiency of singly linked lists and hash tables for inserting, deleting, and searching data records. State Big O notation where appropriate. [6 marks]

题目:比较单链表与哈希表在插入、删除和搜索数据记录方面的效率,适当引用大 O 记号。[6分]

A singly linked list supports constant-time O(1) insertion and deletion at the head, but searching for an arbitrary element requires O(n) time in the worst case because the list must be traversed sequentially. Deletion of a specific node also requires locating its predecessor, which is O(n).

单链表在表头插入和删除的时间复杂度为 O(1),但搜索任意元素最坏需要 O(n) 时间,因为必须顺序遍历链表。删除某个特定节点也需要定位其前驱,同样是 O(n)。

Hash tables utilise a hash function to compute an index into an array of buckets. On average, insertion, deletion, and search are O(1), provided collisions are well managed and the load factor remains low. However, in the worst case (e.g., many collisions resolved by chaining), performance degrades to O(n).

哈希表使用哈希函数计算数组桶的索引。平均情况下,插入、删除和搜索均为 O(1),前提是碰撞得到良好控制且负载因子较低。但在最坏情况下(如大量碰撞由链地址法处理),性能退化为 O(n)。

Consequently, for applications requiring frequent random access and real-time lookups, hash tables are preferred, while linked lists are suitable when insertion order must be preserved or when constant-time insertion at ends is sufficient.

因此,对于需要频繁随机访问和即时查找的应用,哈希表更优;而当需要保留插入顺序或仅需在端部实现常数时间插入时,链表更为合适。


4. Algorithms: Big O Notation & Efficiency | 算法:大O表示法与效率

Question: For each of the following algorithms, state the worst-case and best-case time complexity using Big O notation. Justify your answers briefly: (a) Bubble sort, (b) Merge sort, (c) Binary search. [6 marks]

题目:针对以下每种算法,用大 O 记号说明最坏和最佳情况的时间复杂度,并简要说明理由:(a) 冒泡排序,(b) 归并排序,(c) 二分搜索。[6分]

Algorithm Best Case Worst Case
Bubble Sort O(n) O(n²)
Merge Sort O(n log n) O(n log n)
Binary Search O(1) O(log n)

Bubble sort requires a full pass through the list to confirm no swaps in the best case, giving O(n). In the worst case, the list is in reverse order, requiring n−1 passes each with up to n−1 comparisons, thus O(n²).

冒泡排序在最佳情况下需要遍历一次列表以确认无需交换,为 O(n)。最坏情况下列表完全逆序,需要 n−1 趟,每趟最多 n−1 次比较,故为 O(n²)。

Merge sort divides the list recursively and merges sorted halves in linear time. The depth of recursion is log n, and each level does O(n) work, giving O(n log n) in both best and worst cases.

归并排序递归划分列表并在线性时间内合并有序子列表。递归深度为 log n,每层工作量为 O(n),因此最佳和最坏情况下均为 O(n log n)。

Binary search halves the search interval each step, so the worst-case number of comparisons is logarithmic, O(log n). The best case occurs when the target is at the middle on the first try: O(1).

二分搜索每步将搜索区间减半,因此最坏比较次数为对数级 O(log n)。最佳情况是目标恰好在第一次中点位置:O(1)。


5. Recursion & Problem Decomposition | 递归与问题分解

Question: A recursive function is defined as: F(n) = n * F(n−1) for n>0, with base case F(0)=1. Trace the call stack for F(3), and explain the relationship between recursion and the call stack. [5 marks]

题目:定义一个递归函数:对于 n>0,F(n)=n×F(n−1),基例 F(0)=1。追踪 F(3) 的调用栈,并解释递归与调用栈的关系。[5分]

Tracing F(3): F(3) calls F(2), which calls F(1), which calls F(0). The base case returns 1. Then F(1) returns 1×1=1, F(2) returns 2×1=2, and finally F(3) returns 3×2=6.

追踪 F(3):F(3) 调用 F(2),F(2) 调用 F(1),F(1) 调用 F(0)。基例返回 1。随后 F(1) 返回 1×1=1,F(2) 返回 2×1=2,最后 F(3) 返回 3×2=6。

Each recursive invocation creates a new stack frame containing local variables and the return address. The frames are pushed onto the call stack, and when the base case is reached, frames are popped in LIFO order, allowing values to propagate back through the chain.

每次递归调用都会创建一个新的栈帧,包含局部变量和返回地址。这些帧被压入调用栈,当基例到达时,帧按后进先出的顺序弹出,使得值能通过链回传。

If the base case is missing or recursion never reaches it, the stack overflows due to infinite recursion, highlighting the critical role of the call stack in managing recursion.

如果缺少基例或递归永远无法到达基例,就会因无限递归导致栈溢出,这突显了调用栈在管理递归中的关键作用。


6. Object-Oriented Design: Inheritance & Polymorphism | 面向对象设计:继承与多态

Question: Using a programming example of your choice, explain the concepts of inheritance and polymorphism, and discuss how they promote code reuse and flexibility. [6 marks]

题目:选择一个编程示例,解释继承和多态的概念,并讨论它们如何促进代码重用和灵活性。[6分]

Consider a base class ‘Vehicle’ with an abstract method ‘move()’. Two derived classes, ‘Car’ and ‘Bicycle’, override move() to provide specific behaviour. Inheritance allows ‘Car’ and ‘Bicycle’ to reuse common attributes like ‘speed’ from the parent class without re-implementing them.

考虑基类 ‘Vehicle’,包含抽象方法 ‘move()’。两个派生类 ‘Car’ 和 ‘Bicycle’ 分别覆盖 move() 以提供特定行为。继承使 ‘Car’ 和 ‘Bicycle’ 能够重用父类的通用属性(如 ‘speed’),无需重新实现。

Polymorphism enables a single function to process objects of different derived types through a base-type reference, invoking the appropriate overridden method at runtime. For example, a list of ‘Vehicle’ objects can be iterated, calling move() on each, and dynamic binding ensures the correct version executes.

多态允许单个函数通过基类引用处理不同派生类型的对象,在运行时调用恰当的覆盖方法。例如,可遍历一个 ‘Vehicle’ 对象列表,对每个对象调用 move(),动态绑定确保执行正确的版本。

This design follows the open/closed principle: the system is open for extension (new vehicle types can be added) but closed for modification, as existing code depends only on the base interface.

这种设计遵循开闭原则:系统对扩展开放(可添加新的车辆类型),但对修改关闭,因为现有代码仅依赖于基类接口。


7. Database Systems: SQL Queries & Indexing | 数据库系统:SQL查询与索引

Question: (a) Write an SQL statement to find the names of students who scored above 80 in any subject, from tables Student(id, name) and Result(student_id, subject, mark). (b) Explain how an index on Result.mark would affect the performance of this query. [5 marks]

题目:(a) 编写一条 SQL 语句,从 Student(id, name) 和 Result(student_id, subject, mark) 表中查询任何科目成绩高于 80 分的学生的姓名。(b) 解释在 Result.mark 上创建索引会如何影响该查询的性能。[5分]

SQL: SELECT DISTINCT Student.name FROM Student JOIN Result ON Student.id = Result.student_id WHERE Result.mark > 80;

SQL 语句:SELECT DISTINCT Student.name FROM Student JOIN Result ON Student.id = Result.student_id WHERE Result.mark > 80;

Without an index, the database engine performs a full table scan on the Result table to filter rows where mark > 80, which can be slow for large datasets. With an index on Result.mark, the engine can quickly locate the qualifying rows using a B-tree or similar structure, significantly reducing I/O and improving response time.

没有索引时,数据库引擎对 Result 表执行全表扫描以筛选 mark>80 的行,大数据集下会很慢。而在 Result.mark 上创建索引后,引擎可以利用 B 树等结构快速定位符合条件的行,大幅度减少 I/O 并缩短响应时间。

However, indexes incur overhead on write operations (INSERT, UPDATE, DELETE) because the index structure must be maintained, so a trade-off exists between read speed and write speed.

然而,索引在写操作(INSERT、UPDATE、DELETE)时会带来额外开销,因为必须维护索引结构,因此读取速度与写入速度之间存在权衡。


8. Networks: IP Addressing & Subnetting | 网络:IP地址与子网划分

Question: Given the IP address 192.168.10.45/26, calculate the network ID, the first usable host address, the broadcast address, and the number of available host addresses. Show your working. [5 marks]

题目:给定 IP 地址 192.168.10.45/26,计算网络 ID、第一个可用主机地址、广播地址和可用主机地址的数量。写出计算过程。[5分]

A /26 subnet mask has 26 network bits and 32−26=6 host bits. The mask in decimal is 255.255.255.192. The block size is 2⁶=64. The network ID is found by ANDing the IP with the mask: 192.168.10.0 (since 45 lies in the range 0–63).

/26 子网掩码有 26 位网络位,32−26=6 位主机位。掩码十进制为 255.255.255.192。块大小为 2⁶=64。网络 ID 由 IP 与掩码进行与运算得出:192.168.10.0(因为 45 在 0–63 范围内)。

Network ID = 192.168.10.0, Broadcast = 192.168.10.63

The first usable host is Network ID + 1 = 192.168.10.1. The broadcast address is the last address in the block: 192.168.10.63. The number of usable host addresses is 26−2=62.

第一个可用主机地址为网络 ID+1=192.168.10.1。广播地址为块中最后一个地址:192.168.10.63。可用主机地址数为 2⁶−2=62。


9. Web Technologies: HTTP & REST APIs | 网络技术:HTTP与REST API

Question: Explain the purpose of HTTP status codes, giving one example of a client error and one example of a server error. Describe how a RESTful API uses HTTP methods to perform CRUD operations. [5 marks]

题目:解释 HTTP 状态码的用途,各举一个客户端错误和服务器错误的例子。描述 RESTful API 如何利用 HTTP 方法执行 CRUD 操作。[5分]

HTTP status codes indicate the outcome of an HTTP request. A client error code, such as 404 Not Found, signals that the requested resource could not be located. A server error, like 500 Internal Server Error, indicates an unexpected condition on the server.

HTTP 状态码表示 HTTP 请求的结果。客户端错误码如 404 Not Found,表示无法找到请求的资源。服务器错误如 500 Internal Server Error,表示服务器发生了意外状况。

A RESTful API maps CRUD operations to HTTP methods: Create → POST, Read → GET, Update → PUT or PATCH, and Delete → DELETE. Resources are identified by URIs, and the server responds with appropriate status codes and data in formats such as JSON or XML.

RESTful API 将 CRUD 操作映射到 HTTP 方法:Create → POST,Read → GET,Update → PUT 或 PATCH,Delete → DELETE。资源由 URI 标识,服务器以适当的状态码和数据(如 JSON 或 XML)进行响应。

This stateless design ensures each request contains all necessary information, making the API scalable and easy to cache.

这种无状态设计确保了每个请求包含所有必要信息,使 API 易于扩展并便于缓存。


10. Theory of Computation: Turing Machines & Halting Problem | 计算理论:图灵机与停机问题

Question: Define a Turing machine and explain its significance in computation theory. Outline the Halting Problem and discuss why it is undecidable. [6 marks]

题目:定义图灵机并解释其在计算理论中的意义。概述停机问题,并讨论为何它是不判定的。[6分]

A Turing machine is a mathematical model of computation consisting of an infinite tape divided into cells, a read/write head, a state register, and a transition function. It can simulate any algorithmic process, and the Church‑Turing thesis states that anything computable can be computed by a Turing machine.

图灵机是一种计算数学模型,由无限长的带(划分为单元)、读写头、状态寄存器和转移函数组成。它可以模拟任何算法过程,丘奇‑图灵论题指出,任何可计算的问题都能由图灵机计算。

The Halting Problem asks whether there exists a program that can determine, for any given program-input pair, whether the program will halt or run forever. Turing proved via diagonalisation that no such universal halting decider can exist: if it did, one could construct a paradoxical program that halts if and only if it does not halt.

停机问题询问是否存在一个程序,能够对任意给定的程序-输入对判定该程序会停机还是永久运行。图灵通过对角线法证明不存在通用的停机判定器:如果存在,则可以构造一个自相矛盾的程序,它停机当且仅当它不停机。

Thus the Halting Problem is undecidable, establishing fundamental limits on what computers can solve and forming a cornerstone of computability theory.

因此,停机问题是不可判定的,确立了计算机可解决问题的根本限制,并成为可计算性理论的基石。


Published by TutorHao | 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课程辅导,国外大学本科硕士研究生博士课程论文辅导

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