A-Level AQA Computer Science: Calculation Practice Drills | A-Level AQA 计算机:计算题专项训练

📚 A-Level AQA Computer Science: Calculation Practice Drills | A-Level AQA 计算机:计算题专项训练

In the AQA A-Level Computer Science exams, calculation-based questions regularly appear across topics such as data representation, Boolean logic, processor performance, networking, and algorithms. These questions test your ability to apply quantitative reasoning under time pressure. This article provides a structured practice drill covering the most common calculation scenarios, complete with step‑by‑step examples and dual‑language explanations to reinforce both technical precision and conceptual clarity.

在AQA A-Level 计算机科学考试中,计算类题目频繁出现在数据表示、布尔逻辑、处理器性能、网络和算法等主题中。这些题目考查你在时间压力下应用定量推理的能力。本文提供了一份结构化的专项训练,涵盖了最常见的计算场景,并配有分步示例和双语解释,以同时强化技术准确性与概念清晰度。


1. Binary Addition and Overflow Detection | 二进制加法与溢出检测

In AQA Computer Science, you are frequently required to add 8‑bit two’s complement integers and determine whether the result produces an overflow. Two’s complement representation uses the most significant bit as a sign bit—0 indicates positive, and 1 indicates negative. The range for signed 8‑bit numbers is −128 to +127.

在AQA计算机科学中,你经常需要对8位二进制补码整数进行加法运算,并判断结果是否产生溢出。补码表示法使用最高有效位作为符号位——0表示正数,1表示负数。有符号8位数的表示范围是−128到+127。

Overflow occurs when the sum of two numbers falls outside this representable range. A reliable detection rule: overflow has occurred if both operands have the same sign and the result has the opposite sign. Note that a carry out of the most significant bit alone is not sufficient to indicate overflow in two’s complement arithmetic; the sign change condition must be checked.

当两个数的和超出该可表示范围时,即发生溢出。一个可靠的检测规则是:如果两个操作数具有相同的符号,而结果却具有相反的符号,则发生了溢出。请注意,在补码运算中,仅有最高位的进位并不足以指示溢出;必须检查符号位的变化条件。

Example: Add 01101001₂ (+105) and 01110010₂ (+114).

示例:计算 01101001₂ (+105) 与 01110010₂ (+114) 的和。

01101001₂ + 01110010₂ = 11011011₂

The operands are both positive (sign 0), but the result has a sign bit of 1, indicating a negative number in two’s complement. The expected sum +219 exceeds the +127 limit, so overflow has occurred.

这两个操作数均为正数(符号位0),但结果的符号位为1,在补码中表示负数。预期的和+219超出了+127的上限,因此发生了溢出。


2. Floating Point Normalisation | 浮点数规格化

AQA often uses a simplified floating‑point format to test normalisation and decimal conversion. Consider a 12‑bit representation: 1 bit for the sign, 4 bits for the exponent with an excess‑7 bias, and 7 bits for the normalised mantissa (with the leading 1 implied). To obtain the value, you calculate (−1)^sign × (1 + mantissa fraction) × 2^(exponent − bias).

AQA经常使用一种简化的浮点格式来考查规格化和十进制转换。考虑一个12位的表示:1位符号位,4位阶码,采用移7码(excess‑7),7位规格化尾数(隐含前导位1)。要获得真值,需要计算 (−1)^符号 × (1 + 尾数小数部分) × 2^(阶码 − 偏置值)。

Given the bit pattern 0 1010 1101000. The exponent field 1010₂ = 10; subtract the bias 7 to get an actual exponent of 3. The mantissa bits after the implied binary point give 0.1101000₂, so the significand is 1.1101000₂. The value is 1.1101₂ × 2³ = 1110.1₂ = 14.5 in decimal.

给定二进制模式 0 1010 1101000。阶码字段 1010₂ = 10;减去偏置7,得到实际指数3。尾数位在小数点后部分为 0.1101000₂,因此有效数为 1.1101000₂。该数值为 1.1101₂ × 2³ = 1110.1₂ = 14.5(十进制)。

To normalise a decimal number such as −6.25, first express it as a binary: −110.01₂ = −1.1001₂ × 2². The sign bit is 1, the actual exponent 2 is stored as 2+7 = 9 (1001₂), and the mantissa (without the leading 1) becomes 1001000. The full representation is 1 1001 1001000.

要将十进制数如−6.25规格化,首先将其转为二进制:−110.01₂ = −1.1001₂ × 2²。符号位为1,实际指数2存储为 2+7 = 9 (1001₂),尾数(去掉前导1)变为1001000。完整的表示为 1 1001 1001000。


3. Boolean Algebra and Karnaugh Map Simplification | 布尔代数与卡诺图化简

Simplifying Boolean expressions reduces logic gate count and cost. Algebraic laws, such as distribution, absorption, and De Morgan’s theorems, are essential. For example, simplify F = ¬A·B·¬C + ¬A·B·C + A·B·¬C.

化简布尔表达式可以减少逻辑门数量并降低成本。分配律、吸收律和德摩根定理等代数定律是必不可少的。例如,化简表达式 F = ¬A·B·¬C + ¬A·B·C + A·B·¬C。

Notice that ¬A·B·¬C + ¬A·B·C = ¬A·B·(¬C + C) = ¬A·B. Then F = ¬A·B + A·B·¬C. Factor B: F = B·(¬A + A·¬C). Using the rule x + x’·y = x + y, we set x = ¬A, so ¬A + A·¬C = ¬A + ¬C. Hence F = B·(¬A + ¬C).

注意到 ¬A·B·¬C + ¬A·B·C = ¬A·B·(¬C + C) = ¬A·B。于是 F = ¬A·B + A·B·¬C。提取公因子B:F = B·(¬A + A·¬C)。利用公式 x + x’·y = x + y,令 x = ¬A,则 ¬A + A·¬C = ¬A + ¬C。因此 F = B·(¬A + ¬C)。

Alternatively, a 3‑variable Karnaugh map can verify this result. Below is the K‑map for F (C down, AB across).

或者,也可以使用3变量卡诺图来验证此结果。下面是F的卡诺图(纵向为C,横向为AB)。

00 (¬A¬B) 01 (¬AB) 11 (AB) 10 (A¬B)
C=0 0 1 1 0
C=1 0 1 0 0

Grouping the two adjacent 1s in the ¬AB column gives the prime implicant ¬A·B. The other group in the AB row under C=0 combines A·B·¬C and ¬A·B·¬C to yield B·¬C. The minimal expression is therefore B·¬C + ¬A·B, which matches the algebraic simplification.

将 ¬AB 列中的两个相邻的1圈起来得到质蕴含项 ¬A·B。另一个组合是C=0行中AB列的两个1,结合 A·B·¬C 和 ¬A·B·¬C 得到 B·¬C。因此最简表达式为 B·¬C + ¬A·B,与代数化简结果一致。


4. Processor Performance: Clock Speed and CPI | 处理器性能:时钟频率与CPI

The execution time of a program on a CPU is given by the fundamental equation: Execution Time = (Instruction Count × CPI) / Clock Frequency, where CPI is the average number of clock cycles per instruction. In AQA questions, you must often compare two processors or evaluate the effect of an architectural improvement.

程序在CPU上的执行时间由基本公式给出:执行时间 = (指令数 × CPI) / 时钟频率,其中CPI是每条指令的平均时钟周期数。在AQA题目中,你经常需要比较两个处理器或评估架构改进的效果。

Worked example: A program has 2000 instructions with an average CPI of 1.5. The processor runs at 3 GHz. Calculate the execution time.

具体示例:一个程序包含2000条指令,平均CPI为1.5,处理器运行频率为3 GHz。请计算执行时间。

Execution Time = (2000 × 1.5) / (3 × 10⁹) = 3000 / (3×10⁹) = 1 × 10⁻⁶ s = 1 μs

If the clock frequency is increased to 4 GHz while the instruction count and CPI remain unchanged, the new execution time becomes (2000 × 1.5) / (4×10⁹) = 0.75 μs. This represents a 25% reduction in execution time.

若将时钟频率提升至4 GHz,而指令数和CPI保持不变,则新的执行时间为 (2000 × 1.5) / (4×10⁹) = 0.75 μs,体现出25%的执行时间减少。


5. Memory and Storage Calculations | 内存与存储计算

Address bus width determines the directly addressable memory space. A 32‑bit address bus can access 2³² unique locations. If each memory location stores one byte, the total capacity is 2³² bytes = 4 GB. You must be able to convert between address width and memory size, and understand the effect of extra address lines.

地址总线宽度决定了可直接寻址的存储空间。一条32位的地址总线可访问 2³² 个唯一单元。如果每个存储单元存放一个字节,则总容量为 2³² 字节 = 4 GB。你必须能够在地址宽度和内存大小之间进行转换,并理解增加地址线的影响。

For secondary storage, especially magnetic disks, you need to calculate the average access time. It is the sum of average seek time, average rotational latency, and the transfer time. Rotational latency depends on the rotational speed: half the time for one full revolution. For a disk spinning at 7500 RPM, one revolution takes (60 s / 7500) = 0.008 s = 8 ms. Average rotational latency is 4 ms.

对于二级存储,尤其是磁盘,你需要计算平均访问时间。它是平均寻道时间、平均旋转延迟和传输时间之和。旋转延迟取决于转速:转一圈所需时间的一半。对于转速为7500 RPM的磁盘,转一圈耗时 (60 s / 7500) = 0.008 s = 8 ms,平均旋转延迟为4 ms。

If the average seek time is 6 ms and the sustained transfer rate is 100 MB/s, transfer time for an 8 KB file is (8 / (100×10³)) ms = 0.08 ms. Hence, average total access time ≈ 6 + 4 + 0.08 = 10.08 ms.

如果平均寻道时间为6 ms,持续传输率为100 MB/s,则一个8 KB文件的传输时间为 (8 / (100×10³)) ms = 0.08 ms。因此,平均总访问时间大约为 6 + 4 + 0.08 = 10.08 ms。


6. Network Calculations: Transmission and Propagation Delay | 网络计算:传输延迟与传播延迟

When a packet travels from source to destination, the total delay consists of transmission delay (time to push all bits onto the wire) and propagation delay (time for a signal to travel the physical distance). Transmission delay = Packet size / Bandwidth. Propagation delay = Distance / Propagation speed (usually given). In AQA, you may also include processing and queuing delays but the focus is on the first two.

当数据包从源端传输到目的端时,总时延由传输延迟(将所有比特推入链路的时间)和传播延迟(信号在物理介质中传播的时间)组成。传输延迟 = 数据包大小 / 带宽。传播延迟 = 距离 / 传播速度(通常给定)。在AQA考试中,可能还包括处理和排队延迟,但重点是前两者。

Example: A 1000‑byte packet is sent over a 10 Mbps link with a propagation delay of 10 ms. Transmission delay = (1000 × 8 bits) / (10×10⁶ bps) = 8000 / 10⁷ = 0.0008 s = 0.8 ms. Total delay = 0.8 ms + 10 ms = 10.8 ms. The propagation delay dominates in this scenario.

示例:一个1000字节的数据包通过一条带宽为10 Mbps的链路发送,传播延迟为10 ms。传输延迟 = (1000 × 8 bit) / (10×10⁶ bps) = 8000 / 10⁷ = 0.0008 s = 0.8 ms。总时延 = 0.8 ms + 10 ms = 10.8 ms。在此场景中,传播延迟占主导地位。


7. Algorithm Complexity: Step Count and Big‑O | 算法复杂度:步数统计与大O符号

Determining the time complexity of an algorithm often starts by counting the number of elementary operations as a function of input size n. For the following nested loop:

确定算法的时间复杂度通常从统计基本操作次数开始,将其表示为输入规模n的函数。对于以下嵌套循环:

for i = 1 to n
for j = 1 to i
sum = sum + 1

The inner loop executes i times for each i, giving total executions 1 + 2 + … + n = n(n+1)/2. The dominating term is n²/2, so the time complexity is O(n²).

内层循环对于每个i执行i次,总执行次数为 1 + 2 + … + n = n(n+1)/2。主要项为 n²/2,因此时间复杂度为 O(n²)。

When estimating step counts, you often count comparisons, assignments, and arithmetic operations. In AQA, you may be required to express the exact step count formula and then deduce the Big‑O notation by discarding constant factors and lower‑order terms.

在估计步数时,你通常要统计比较次数、赋值次数和算术运算次数。在AQA考试中,你可能需要写出精确的步数公式,然后通过舍弃常数因子和低阶项推导出大O表示法。


8. Data Structures: Binary Search Tree Comparisons | 数据结构:二叉搜索树的比较次数

Binary search trees (BSTs) organise data to allow efficient searching. The number of comparisons needed to locate a key depends on the tree’s height. In the best case, the tree is balanced, giving a height of ⌊log₂ n⌋ and thus O(log n) search time. In the worst case, the tree degenerates into a linked list (e.g., inserting sorted data without balancing), resulting in O(n) comparisons.

二叉搜索树(BST)通过组织数据以支持高效搜索。查找一个关键字所需的比较次数取决于树的高度。在最好情况下,树是平衡的,高度为 ⌊log₂ n⌋,因此搜索时间为 O(log n)。在最坏情况下,树退化为链表(例如未做平衡而按排序顺序插入数据),导致比较次数为 O(n)。

Given the sequence 15, 10, 20, 8, 12, 18, 25 inserted into an initially empty BST, the tree is reasonably balanced. Searching for 12 requires comparing with 15 (go left), 10 (go right), and finally 12—total 3 comparisons. A quick rule: the maximum number of comparisons to reach a leaf equals the number of nodes on the path; the average successful search length depends on the shape.

给定依次插入初始为空BST的序列 15, 10, 20, 8, 12, 18, 25,构建的树相当平衡。搜索12需要进行与15比较(向左)、与10比较(向右),最后与12比较——总共3次比较。一个简单规则:达到叶结点的最大比较次数等于路径上的结点数;平均成功查找长度取决于树的形状。


9. Assembly Language: Effective Address Calculation | 汇编语言:有效地址计算

In AQA’s assembly language, the LDR instruction can use register indirect and indexed addressing. For example, LDR R1, [R2, R3, LSL #2] computes the effective address by taking the base in R2, adding the value in R3 after it has been logically shifted left by 2 bits (i.e., multiplied by 4). This is useful for accessing arrays where each element is 4 bytes.

在AQA的汇编语言中,LDR指令可以使用寄存器间接寻址和变址寻址。例如,LDR R1, [R2, R3, LSL #2] 通过取R2中的基址,加上R3值逻辑左移2位(即乘以4)之后的结果来计算有效地址。这对于访问每个元素为4字节的数组非常有用。

If R2 = 1000 (base address of an array) and R3 = 10 (index for the 10th element), the effective address is 1000 + (10 × 4) = 1040. The value stored at memory address 1040 is loaded into R1. This calculation is typical for structured questions on addressing modes.

如果 R2 = 1000(数组基地址),R3 = 10(第10个元素的索引),则有效地址为 1000 + (10 × 4) = 1040。内存地址1040中存储的值将被加载到R1。这种计算是寻址方式结构化试题的典型内容。


10. Scheduling Algorithms: Turnaround Time | 调度算法:周转时间

CPU scheduling algorithms are evaluated using metrics such as turnaround time (completion time − arrival time) and waiting time. A common AQA calculation involves applying First‑Come, First‑Served (FCFS) and Shortest Job First (SJF) to a set of processes and computing the average turnaround time.

CPU调度算法通常使用周转时间(完成时间 − 到达时间)和等待时间等指标来评估。常见的AQA计算题会要求对一组进程应用先来先服务(FCFS)和最短作业优先(SJF),并计算平均周转时间。

Consider three processes with arrival times and burst times: P1 (arrival 0, burst 8), P2 (arrival 1, burst 4), P3 (arrival 2, burst 2). Under FCFS, execution order is P1, P2, P3. Completion times: P1 = 8, P2 = 12, P3 = 14. Turnaround times: P1 = 8−0=8, P2 = 12−1=11, P3 = 14−2=12. Average = (8+11+12)/3 = 10.33 time units.

假设有三个进程及其到达时间和执行时间:P1(到达0,执行8),P2(到达1,执行4),P3(到达2,执行2)。在FCFS下,执行顺序为P1、P2、P3。完成时间:P1=8,P2=12,P3=14。周转时间:P1=8−0=8,P2=12−1=11,P3=14−2=12。平均周转时间 = (8+11+12)/3 = 10.33 时间单位。

With SJF (non‑preemptive, considering processes that have arrived by the time the CPU becomes idle), at time 0, only P1 is available and runs. It finishes at time 8; by then, both P2 and P3 have arrived. The scheduler picks P3 (burst 2) next, finishing at 10, then P2 finishes at 14. Turnaround times: P1=8, P3=10−2=8, P2=14−1=13, average = 9.67. This demonstrates the improved average turnaround with SJF.

采用SJF(非抢占式,考虑CPU空闲时已到达的进程),在时刻0只有P1可用并运行。它在时刻8完成;此时P2和P3均已到达。调度器接下来选择P3(执行时间2),完成于10,然后P2完成于14。周转时间:P1=8,P3=10−2=8,P2=14−1=13,平均为9.67。这体现了SJF对平均周转时间的改善效果。


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