Mastering Calculations in A-Level WJEC Computer Science | A-Level WJEC 计算机科学计算题专项训练

📚 Mastering Calculations in A-Level WJEC Computer Science | A-Level WJEC 计算机科学计算题专项训练

Calculation questions form a significant part of the A-Level WJEC Computer Science examination. They test your ability to apply theoretical knowledge to concrete numerical problems, covering topics from binary arithmetic and logic simplification to processor performance and networking. This intensive training guide breaks down the most common calculation-based question types into step-by-step strategies, complete with worked examples and bilingual explanations, so you can approach your exam with confidence and precision.

计算题在 A-Level WJEC 计算机科学考试中占有相当大的比重。它们考查你将理论知识应用于具体数值问题的能力,涵盖从二进制算术、逻辑化简到处理器性能和网络等多个主题。这份专项训练指南把最常见的计算类题型分解为分步解题策略,并配有完整的例题和双语解释,让你在考场上能够自信而准确地作答。


1. Binary and Hexadecimal Conversions | 二进制与十六进制转换

Conversions between denary, binary, and hexadecimal are foundational. For WJEC papers, you must be able to convert unsigned integers quickly. To go from denary to binary, repeatedly divide by 2 and read remainders upwards. To go from binary to hexadecimal, group the binary digits into nibbles (groups of 4) from the right, then replace each nibble with its hex equivalent (0‑9, A‑F). In the reverse direction, expand each hex digit into a 4‑bit binary group.

十进制、二进制和十六进制之间的转换是基础中的基础。在 WJEC 试卷中,你必须能够快速转换无符号整数。十进制转二进制:不断除以 2,并将余数从下往上读取。二进制转十六进制:从右侧开始将二进制数字每四位分为一组(nibble),然后将每一组替换为对应的十六进制符号(0‑9, A‑F)。反向转换时,将每个十六进制数字展开为一个 4 位的二进制组。

Example: Convert denary 219 to binary and then to hexadecimal. 219 ÷ 2 = 109 R1; 109 ÷ 2 = 54 R1; 54 ÷ 2 = 27 R0; 27 ÷ 2 = 13 R1; 13 ÷ 2 = 6 R1; 6 ÷ 2 = 3 R0; 3 ÷ 2 = 1 R1; 1 ÷ 2 = 0 R1. Reading remainders upwards gives 11011011₂. Group into nibbles: 1101 1011 → D B → DB₁₆.

例题:将十进制 219 转为二进制,再转为十六进制。219 ÷ 2 = 109 余1;109 ÷ 2 = 54 余1;54 ÷ 2 = 27 余0;27 ÷ 2 = 13 余1;13 ÷ 2 = 6 余1;6 ÷ 2 = 3 余0;3 ÷ 2 = 1 余1;1 ÷ 2 = 0 余1。从下往上读取余数得 11011011₂。分组:1101 1011 → D B → DB₁₆。


2. Binary Arithmetic and Overflow | 二进制算术与溢出

Addition and subtraction of binary numbers follow the same place‑value principles as denary. For addition, remember 0+0=0, 0+1=1, 1+1=10 (carry 1). For subtraction, you may use two’s complement to turn it into addition. An 8‑bit overflow occurs when the result of an addition exceeds the representable range (–128 to +127 for signed two’s complement). Detect overflow by checking if the carry into the sign bit (bit 7) differs from the carry out of the sign bit.

二进制数的加法和减法遵循与十进制相同的位值原则。加法牢记:0+0=0,0+1=1,1+1=10(进1)。减法可借助二进制补码将其转化为加法。当加法运算的结果超出可表示范围(有符号补码下 –128 到 +127)时,便发生 8 位溢出。通过检查符号位(第7位)的“进位输入”与“进位输出”是否不同,可以检测溢出。

Example: Perform 01100110₂ + 00111001₂. Starting from rightmost bit: 0+1=1; 1+1=10 (write 0, carry 1); 1+0+0=1; 0+1=1; 1+1=10; 1+0+1=10; 0+0+1=1. Result: 10011111₂. The carry into sign bit (bit 7, here bit 7 is leftmost) was 1 and carry out of sign bit was 0; they differ, so overflow occurs (unsigned interpretation: 102+57=159, which is within 0‑255, but for signed it is –97, incorrectly).

例题:计算 01100110₂ + 00111001₂。从最右位开始:0+1=1;1+1=10(写0进1);1+0+0=1;0+1=1;1+1=10(写0进1);1+0+1=10(写0进1);0+0+1=1。结果:10011111₂。进位到符号位(这里是第7位)是1,从符号位进位输出是0;两者不同,故发生溢出(无符号解释:102+57=159,仍在0‑255内,但作为有符号数则错误地成了 –97)。


3. Floating Point Representation | 浮点数表示

WJEC often uses a simplified floating‑point format with a mantissa and exponent, both in two’s complement. A number is built as mantissa × 2exponent. To convert a denary fraction to the format, first write it in binary fixed‑point form, then normalise by shifting the binary point until the number is in the form 1.xx… for positive numbers or 0.1xx… for negative fractions, matching the two’s complement sign rule. The number of shifts becomes the exponent. Watch out for precision limits and the range of representable numbers.

WJEC 常采用一种简化的浮点格式,由补码表示的尾数和指数构成。数字构成为 尾数 × 2指数。要将一个十进制小数转换为该格式,先将其写成定点二进制形式,然后通过移动二进制小数点使其规格化:正数应为 1.xx… 形式,负数分数应为 0.1xx… 形式(符合补码符号规则)。移动的位数即为指数。要注意精度限制和可表示范围。

Example: Represent +3.625 in an 8‑bit mantissa, 4‑bit exponent format. 3.625₁₀ = 11.101₂. Normalise: shift binary point left so that it becomes 1.1101 × 2¹. Mantissa is 0.1110100 with sign extension (positive, leading 0); exponent is +1, which in 4‑bit two’s complement is 0001. Final representation: mantissa 01110100, exponent 0001. (Check: 0.11101 × 2¹ = 1.1101 = 3.625).

例题:在 8 位尾数、4 位指数的格式中表示 +3.625。3.625₁₀ = 11.101₂。规格化:将二进制点左移,变成 1.1101 × 2¹。尾数为 0.1110100(正数前导 0,符号扩展);指数为 +1,4 位补码为 0001。最终表示:尾数 01110100,指数 0001。(检验:0.11101 × 2¹ = 1.1101 = 3.625)。


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

Boolean expression manipulation is a common calculation task. You must apply identities such as commutative, associative, distributive, De Morgan’s theorems, and absorption to reduce a logic expression to its minimal sum‑of‑products form. Questions may ask you to simplify a given expression and then draw the corresponding logic circuit. Work step‑by‑step, clearly showing each algebraic transformation.

布尔表达式化简是常见的计算任务。你需要运用交换律、结合律、分配律、德摩根定理和吸收等恒等式,将逻辑表达式化简为最简积之和形式。考题可能要求你先化简给定表达式,再画出相应的逻辑电路。解题时应分步进行,清晰展示每一次代数变换。

Example: Simplify F = A·B + A·(¬B + C) + B·(¬A + C).
Step 1: Expand A·(¬B + C) = A·¬B + A·C.
Step 2: Expand B·(¬A + C) = B·¬A + B·C.
Now F = A·B + A·¬B + A·C + B·¬A + B·C.
Step 3: Group A·B + A·¬B = A·(B+¬B) = A.
Step 4: A + A·C = A (absorption).
Step 5: So far we have A + B·¬A + B·C. B·¬A + A = A + B (since A + ¬A·B = A + B).
Final expression: F = A + B + B·C = A + B (absorption again). Thus minimal form is A + B.

例题:化简 F = A·B + A·(¬B + C) + B·(¬A + C)。
第1步:展开 A·(¬B + C) = A·¬B + A·C。
第2步:展开 B·(¬A + C) = B·¬A + B·C。
现在 F = A·B + A·¬B + A·C + B·¬A + B·C。
第3步:合并 A·B + A·¬B = A·(B+¬B) = A。
第4步:A + A·C = A(吸收律)。
第5步:至此有 A + B·¬A + B·C。B·¬A + A = A + B(因为 A + ¬A·B = A + B)。
最终表达式:F = A + B + B·C = A + B(再次吸收)。最简形式为 A + B。


5. Karnaugh Maps for Simplification | 卡诺图化简

Karnaugh maps (K‑maps) provide a visual method to minimise Boolean functions of 2, 3, or 4 variables. Calculations involve filling the map from a truth table or expression, forming the largest possible groups of 1s (group sizes must be powers of 2: 1,2,4,8), and reading off the simplified terms where a variable that changes within a group is eliminated. Overlapping groups are allowed, and you must cover all 1s with the fewest groups.

卡诺图为二、三、四变量的布尔函数提供了一种直观的最小化方法。计算过程包括根据真值表或表达式填写图格、将1圈成尽可能大的组(组的大小必须为2的幂:1、2、4、8),然后读出简化项,在组内发生变化的变量被消去。组可以重叠,并且必须用最少的组覆盖所有的1。

Example: Minimise F(A,B,C) = Σ(1,2,3,6,7) using a 3‑variable K‑map. Map layout: AB on one axis, C on the other. Fill cells: m1=001, m2=010, m3=011, m6=110, m7=111. Group 1: cells 2,3,6,7 form a quad (B changes, A stays 1? Actually goup: m2(010), m3(011), m6(110), m7(111) — here A and B change? Wait, in correct map arrange 00,01,11,10 for AB. m2=010 → AB=01,C=0; m3=011 → AB=01,C=1; m6=110 → AB=11,C=0; m7=111 → AB=11,C=1. This quad eliminates A? No, AB goes from 01 to 11, so A changes; C changes. The common term: B remains 1? Looking: AB=01 and 11 both have B=1, C varies. So term is B. Group 2: m1(001) and m3(011) form pair, AB=00,01 with C=1, simplifies to ¬A·C. Combined result: F = B + ¬A·C.

例题:用三变量卡诺图化简 F(A,B,C) = Σ(1,2,3,6,7)。布局:AB为轴,C为另一轴。填图:m1=001, m2=010, m3=011, m6=110, m7=111。第1组:2,3,6,7 构成四格组(m2(010),m3(011),m6(110),m7(111) — AB 在 01 与 11 间变化,C变化,共同项为 B=1,故项为 B)。第2组:m1(001) 和 m3(011) 成对,AB=00,01 且 C=1,化简为 ¬A·C。最终结果:F = B + ¬A·C。


6. Processor Performance Calculations | 处理器性能计算

Key formulae for WJEC: execution time = instruction count × CPI × clock cycle time, or alternatively execution time = (instruction count × CPI) / clock frequency. CPI (cycles per instruction) may be given or calculated from a mix of instruction classes. Clock cycle time = 1 / frequency. Be ready to compute MIPS (millions of instructions per second) = clock rate / (CPI × 10⁶). Always ensure units are consistent (e.g., GHz to Hz or ns to seconds).

WJEC 核心公式:执行时间 = 指令数 × CPI × 时钟周期,或 执行时间 = (指令数 × CPI) / 时钟频率。CPI(每条指令周期数)可能直接给出,或需根据指令类别混合计算。时钟周期 = 1 / 频率。要会计算 MIPS(每秒百万指令数)= 时钟频率 / (CPI × 10⁶)。务必确保单位一致(如 GHz 换为 Hz,ns 换为秒)。

Example: A program has 200 million instructions, CPI = 1.5, and the processor clock frequency is 2 GHz. Calculate execution time. Frequency f = 2×10⁹ Hz, cycle time = 1/f = 0.5×10⁻⁹ s = 0.5 ns. Execution time = 200×10⁶ × 1.5 × 0.5×10⁻⁹ = 0.15 seconds. Alternatively, time = (200M × 1.5) / 2 GHz = 300M / 2×10⁹ = 0.15 s.

例题:某程序有 2 亿条指令,CPI = 1.5,处理器时钟频率为 2 GHz。计算执行时间。频率 f = 2×10⁹ Hz,时钟周期 = 1/f = 0.5×10⁻⁹ s = 0.5 ns。执行时间 = 200×10⁶ × 1.5 × 0.5×10⁻⁹ = 0.15 秒。或者,时间 = (200M × 1.5) / 2 GHz = 300M / 2×10⁹ = 0.15 s。


7. Memory and Storage Calculations | 存储器计算

Memory chip capacity is determined by address lines and data lines. With ‘n’ address lines, you can uniquely address 2ⁿ memory locations. If each location stores ‘m’ bits (data width), total capacity = 2ⁿ × m bits. A common task: given a memory spec, deduce the number of address pins, or calculate the range of addresses (often in hexadecimal). You may also need to compute the number of chips required to build a larger memory module.

存储芯片的容量由地址线和数据线决定。n 条地址线可唯一寻址 2ⁿ 个存储单元。若每个单元存储 m 位(数据宽度),总容量 = 2ⁿ × m 位。常见题型:给定存储器规格,推算地址引脚数量,或计算地址范围(通常用十六进制)。你可能还需要计算构建特定内存模块所需的芯片数量。

Example: A RAM chip has 12 address lines and 8 data lines. Give its capacity in bytes. Number of locations = 2¹² = 4096. Each location is 8 bits = 1 byte. Capacity = 4096 × 1 byte = 4 KB. The address range is from 0x000 to 0xFFF (12 bits). If we wanted a 16 KB memory using these chips, we would need 16 KB / 4 KB = 4 chips, and an extra 2 address lines for chip selection (since log₂4=2).

例题:一块 RAM 芯片有 12 条地址线、8 条数据线。给出其以字节为单位的容量。存储单元数 = 2¹² = 4096。每单元 8 位 = 1 字节。容量 = 4096 × 1 字节 = 4 KB。地址范围从 0x000 到 0xFFF(12 位)。若希望用此芯片构建 16 KB 内存,需要 16 KB / 4 KB = 4 片,并额外需 2 条地址线用于片选(因 log₂4=2)。


8. Network Address Calculations | 网络地址计算

IP subnetting calculations are critical. Given an IP address and a subnet mask (or slash notation), identify the network address (bitwise AND of IP and mask), broadcast address (network address with host bits set to 1), and the range of usable host addresses. For classless addressing, the number of subnets = 2borrowed bits, and hosts per subnet = 2host bits – 2 (excluding network and broadcast). You must also be able to convert between CIDR notation and dotted decimal masks.

IP 子网划分的计算至关重要。给定 IP 地址和子网掩码(或斜线记法),确定网络地址(IP 与掩码按位与)、广播地址(网络地址的主机位全设为1)以及可用主机地址范围。对于无类寻址,子网数 = 2借位数,每个子网的主机数 = 2主机位数 – 2(去掉网络和广播地址)。你还必须会在 CIDR 记法和点分十进制掩码间转换。

Example: IP 192.168.10.35/27. Mask = 27 ones: 255.255.255.224. In binary, last octet mask = 11100000. IP last octet 35 = 00100011. Network address: 192.168.10. (35 & 224) = 192.168.10.32. Host bits = 5, so block size = 2⁵ = 32. Broadcast address = 192.168.10.63. Useable hosts: 192.168.10.33 – 192.168.10.62.

例题:IP 192.168.10.35/27。掩码为 27 个 1:255.255.255.224。最后一个八位组掩码 = 11100000。IP 最后一组 35 = 00100011。网络地址:192.168.10. (35 & 224) = 192.168.10.32。主机位 = 5,块大小 = 2⁵ = 32。广播地址 = 192.168.10.63。可用主机范围:192.168.10.33 – 192.168.10.62。


9. Algorithm Complexity and Step Counting | 算法复杂度与步骤计数

Calculating time complexity for given algorithms is a WJEC requirement. You must count the number of fundamental operations (e.g., comparisons, assignments) as a function of input size N, then deduce the Big‑O order. For simple loops, the total operations = number of iterations × operations per iteration. Nested loops multiply. Also, you may need to evaluate the number of steps in searching and sorting algorithms (linear search: worst case N; binary search: log₂N; bubble sort: N²/2).

计算给定算法的时间复杂度是 WJEC 的要求。你需要将基本操作(如比较、赋值)的数目表示为输入规模 N 的函数,再推导出大 O 阶。对于简单循环,总操作数 = 迭代次数 × 每次迭代操作数。嵌套循环相乘。此外,可能需要评估搜索和排序算法的步骤数(线性搜索:最坏 N;二分搜索:log₂N;冒泡排序:N²/2)。

Example: Analyse the loop: for i = 1 to N: for j = 1 to i: print i,j. The inner loop executes i times, so total prints = 1+2+…+N = N(N+1)/2. This simplifies to O(N²). In exact step counting, if print is 1 operation, the total is roughly N²/2.

例题:分析循环:for i = 1 to N: for j = 1 to i: print i,j。内层循环执行 i 次,故总打印次数 = 1+2+…+N = N(N+1)/2。这简化为 O(N²)。在精确步骤计数中,若 print 算一次操作,总数约为 N²/2。


10. Hashing and Collision Resolution | 哈希与碰撞处理

Hash table calculations require you to insert keys using a given hash function, often h(key)=key mod table size, and resolve collisions via linear probing, quadratic probing, or chaining. You must compute the final position of each key and determine the average number of probes (comparisons) for successful and unsuccessful searches. Load factor α = number of entries / table size affects performance. For linear probing, expected number of probes ≈ ½(1 + 1/(1‑α)) for successful search, but WJEC may ask for direct simulation with a small dataset.

哈希表计算要求你使用给定的哈希函数(常为 h(key)=key mod 表大小)插入键,并通过线性探测、二次探测或链地址法解决碰撞。你需要计算每个键的最终位置,确定成功和不成功查找的平均探测次数(比较次数)。负载因子 α = 条目数 / 表大小影响性能。线性探测下成功查找的期望探测次数≈ ½(1 + 1/(1‑α)),但 WJEC 可能要求用一个小数据集直接模拟。

Example: Table size 10, hash h(k)=k mod 10. Insert keys 23, 45, 12, 67, 87 in that order using linear probing. 23 → 3; 45 → 5; 12 → 2; 67 → 7 ( 67 mod 10 = 7, check slot 7 empty); 87 → 7 collision → 8 → 9, so placed in 9. Table slots: 0:empty,1:empty,2:12,3:23,4:empty,5:45,6:empty,7:67,8:empty,9:87. For successful find of 87, it takes 3 probes (slots 7,8,9). Load factor = 5/10 = 0.5.

例题:表大小 10,哈希函数 h(k)=k mod 10。按顺序插入键 23, 45, 12, 67, 87,使用线性探测。23→3;45→5;12→2;67→7 (67 mod 10=7, 空);87→7 碰撞 →8→9,故放入 9。表槽:0空,1空,2:12,3:23,4空,5:45,6空,7:67,8空,9:87。成功查找 87 需 3 次探测(槽 7,8,9)。负载因子 = 5/10 = 0.5。


11. Assembly Language Address Calculations | 汇编语言地址计算

In WJEC’s assembly language models (often a simplified processor like Little Man Computer or an accumulator‑based ISA), calculation questions involve computing effective addresses for indirect, indexed, or base‑relative addressing modes. For example: effective address = base register + offset (in two’s complement). Branches may use PC‑relative addressing: target address = (PC + 1) + signed displacement. You must accurately convert displacements and immediate values between denary and binary/hex.

在 WJEC 的汇编语言模型中(通常是简化处理器,如 Little Man Computer 或基于累加器的指令集架构),计算题涉及计算间接寻址、变址寻址或基址相对寻址的有效地址。例如:有效地址 = 基址寄存器 + 偏移量(补码)。分支可能使用 PC 相对寻址:目标地址 = (PC + 1) + 有符号位移。你必须准确地在十进制与二进制/十六进制间转换位移和立即数。

Example: In an LMC, the instruction at address 05 is BRZ 09 (branch if zero to mailbox 09). If accumulator is zero, the program counter is loaded with 09. But if we use a machine with PC‑relative: instruction at address 20 has a branch instruction with displacement field 0x0A (treat as 8‑bit signed, +10). PC after fetch is 21. Target = 21 + 10 = 31 (decimal). If displacement were 0xF6 (–10), target = 21 – 10 = 11.

例题:在 LMC 中,地址 05 的指令为 BRZ 09(若累加器为零则跳转到邮箱 09)。若累加器为零,程序计数器被加载为 09。但在使用 PC 相对寻址的机器中:地址 20 处有一条分支指令,位移字段为 0x0A(8 位有符号数,+10)。取指后 PC 为 21。目标地址 = 21 + 10 = 31(十进制)。若位移为 0xF6(–10),则目标 = 21 – 10 = 11。


12. Error Detection and Data Integrity Calculations | 差错校验与数据完整性计算

WJEC may include questions on parity bits, checksums, or CRC calculations. For a parity bit system, you count the number of 1s in a data byte and set an even/odd parity bit accordingly. Checksums involve adding data words (often in two’s complement or 1’s complement) and using the truncated sum or its complement as the check value. A sample calculation: Given data bytes, compute the arithmetic sum, keep only the lower byte, and use its one’s complement as the checksum byte.

WJEC 可能包含有关奇偶校验位、校验和或 CRC 计算的问题。对于奇偶校验位系统,你需要统计数据字节中 1 的个数,并据此设置偶校验或奇校验位。校验和则涉及将数据字相加(通常用补码或反码),并用截断的和或其反码作为校验值。计算示例:给定数据字节,计算算术和,只保留低字节,再用其反码作为校验和字节。

Example: Even parity for byte 10110011₂. Number of 1s = 5 (odd), so parity bit is set to 1 to make total 1’s even. Data sent: parity bit + 10110011. Checksum: bytes 0x36, 0x9A, 0x52. Sum = 0x36+0x9A=0xD0; 0xD0+0x52=0x122. Keep lower byte 0x22. One’s complement of 0x22 is 0xDD (by flipping bits: 00100010 → 11011101). Checksum byte = 0xDD.

例题:字节 10110011₂ 的偶校验。1 的个数 = 5(奇数),因此校验位设 1,使总 1 数为偶数。发送数据:校验位 + 10110011。校验和:字节 0x36, 0x9A, 0x52。求和:0x36+0x9A=0xD0;0xD0+0x52=0x122。保留低字节 0x22。0x22 的反码为 0xDD(位翻转:00100010 → 11011101)。校验和字节 = 0xDD。


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