📚 A-Level OCR Computer Science: Calculation Drill Workout | OCR 计算机科学计算题专项训练
Mastering the calculation-style questions in OCR A-Level Computer Science requires both conceptual clarity and fluent arithmetic under exam pressure. This workout walks you through typical problem types—from binary arithmetic to floating‑point normalisation, Boolean simplification, file‑size estimation, and Big‑O analysis—presenting each technique in paired English and Chinese explanations. Work through the examples, check your reasoning, and build speed for papers H046/H446.
掌握 OCR A-Level 计算机科学中的计算类题目,既需要清晰的概念理解,也需要在考试压力下快速准确运算的能力。本专项训练带你遍历典型题型——从二进制算术到浮点数规范化、布尔表达式化简、文件大小估算与大O分析——每个技巧均以中英文对照讲解。跟随示例练习,检验推理过程,为 H046/H446 试卷提速。
1. Binary, Denary and Hexadecimal Conversions | 二进制、十进制与十六进制转换
Start with the core building blocks: converting a denary integer to binary by successive division by 2, reading remainders upwards. For hexadecimal, group bits in fours from the right. The same method reverses: hex digits become nibbles, then join to form binary.
从基础出发:通过连续除以2取余数,从下往上读取余数,将十进制整数转换为二进制。对于十六进制,从右侧开始每四位二进制数分组,然后对应到一个十六进制数字。反向方法同理:十六进制数字展开为四位二进制,再拼接即可。
Example: Convert 218₁₀ to binary and to hex. 218 ÷ 2 = 109 rem 0, 109 ÷ 2 = 54 rem 1, 54 ÷ 2 = 27 rem 0, 27 ÷ 2 = 13 rem 1, 13 ÷ 2 = 6 rem 1, 6 ÷ 2 = 3 rem 0, 3 ÷ 2 = 1 rem 1, 1 ÷ 2 = 0 rem 1. Read backwards: 11011010₂. Group 1101 1010 → D A → DA₁₆. Common OCR question: fill in a conversion table with denary, binary and hex columns.
示例:将 218₁₀ 转换为二进制和十六进制。连续除以2取余数,从下往上得 11011010₂。每四位分组:1101 1010,对应十六进制 D A,即 DA₁₆。OCR 常见题型:填写一个包含十进制、二进制和十六进制列的转换表格。
2. Binary Addition and Subtraction | 二进制加法与减法
Binary addition follows column rules: 0+0=0, 0+1=1, 1+0=1, 1+1=0 carry 1, and 1+1+carry=1 carry 1. Subtraction often uses two’s complement: negate the subtrahend and add. Watch for overflow in fixed‑width registers and be prepared to state the overflow flag condition.
二进制加法按位处理:0+0=0,0+1=1,1+0=1,1+1=0 进位1,1+1+进位=1 进位1。减法常用补码法:将被减数取负后相加。注意固定宽度寄存器中的溢出,并准备说明溢出标志的条件。
Example with 8 bits: 01101001₂ (105) + 00111100₂ (60) = 10100101₂. Here the leftmost bit is 1, but the operands both started with 0; this indicates overflow in signed two’s complement because the sum exceeds +127. OCR will ask you to add, then identify whether overflow occurred and why.
8位示例:01101001₂ (105) + 00111100₂ (60) = 10100101₂。最高位为1,但两个操作数最高位均为0,在带符号补码中这表示溢出,因为和超出了 +127。OCR 会要求你做加法,然后识别是否发生溢出并说明原因。
3. Two’s Complement Negative Numbers | 补码表示负数
To represent a negative denary number in two’s complement: write the positive binary, invert all bits, then add 1. The most significant bit (MSB) acts as the sign bit. To find the denary value of a two’s complement binary, if MSB is 1, treat it as negative: invert bits, add 1, read the magnitude and put a minus sign.
要用补码表示一个负十进制数:写出正数的二进制,将所有位取反,再加1。最高位(MSB)充当符号位。若给定位补码二进制求十进制值,如果 MSB 为1,则视为负数:按位取反,加1,读出绝对值,前面加上负号。
Practice: Represent –47 in 8‑bit two’s complement. +47 = 00101111₂, invert → 11010000, add 1 → 11010001₂. Reverse: given 11010001₂, MSB=1 so negative, invert → 00101110, add 1 → 00101111₂ = 47, so –47. Exam might ask for range: with n bits, signed two’s complement range is –2ⁿ⁻¹ to 2ⁿ⁻¹–1.
练习:用8位补码表示 –47。+47 = 00101111₂,取反 → 11010000,加1 → 11010001₂。反向:给定 11010001₂,MSB=1 为负,取反 → 00101110,加1 → 00101111₂ = 47,故为 –47。考试可能问范围:n位带符号补码范围为 –2ⁿ⁻¹ 到 2ⁿ⁻¹–1。
4. Floating‑Point Binary Normalisation | 浮点二进制规范化
OCR floating‑point questions give a mantissa and exponent (typically in two’s complement). The normalised form ensures the mantissa starts with 01 for positive or 10 for negative, maximising precision. You need to convert a decimal fraction to binary, normalise, adjust the exponent, and then pack the bits.
OCR 浮点题给出尾数和阶码(均为补码形式)。规范化要求尾数以 01(正数)或 10(负数)开头,以最大化精度。你需要将小数转为二进制,规范化,调整阶码,然后将位组合起来。
Example: Represent 3.25 with a 6‑bit mantissa and 4‑bit exponent. 3.25 = 11.01₂. Move binary point to achieve 0.1101: shift left once, so exponent = –1. In two’s complement 4‑bit exponent, –1 = 1111. Mantissa 0.110100 (fill with zeros). Positive, so normalised mantissa is 011010 (leading 01). Combined: 011010 1111. OCR often asks to denormalise a given floating‑point number to denary.
示例:用6位尾数、4位阶码表示 3.25。3.25 = 11.01₂。移动小数点得到 0.1101:向左移一位,因此阶码 = –1。用4位补码表示 –1 = 1111。尾数 0.110100(填充零)。正数,规范化尾数 011010(首位01)。组合:011010 1111。OCR 常要求将给定浮点数逆规范化为十进制。
5. Logic Gates and Truth Table Calculations | 逻辑门与真值表计算
Given a logic circuit diagram, construct the truth table by working through intermediate outputs. Count the number of inputs; the table has 2ⁿ rows. Systematically fill columns and derive the final output. Be ready to convert between Boolean expression and diagram, and to simplify using identities.
给出逻辑电路图,通过计算中间输出来构建真值表。确定输入个数,表格有 2ⁿ 行。系统地填写各列并推导最终输出。准备好在布尔表达式与电路图之间转换,并运用恒等式化简。
For a circuit with inputs A, B and an AND gate feeding a NOT, then an OR gate combining with another input C: expression Q = ¬(A ∧ B) ∨ C. The truth table columns: A, B, A∧B, ¬(A∧B), C, Q. OCR calculation might involve finding the output for a specific vector or drawing timing diagrams.
以输入 A、B 经与门再经非门,然后与输入 C 经或门组合的电路为例:表达式 Q = ¬(A ∧ B) ∨ C。真值表列:A, B, A∧B, ¬(A∧B), C, Q。OCR 的计算可能涉及求特定输入向量下的输出,或绘制时序图。
6. Boolean Algebra Simplification | 布尔代数化简
OCR features algebraic simplification using laws: commutative, associative, distributive, identity, complement, idempotent, absorption, and De Morgan’s. The goal is to reduce a given expression to its simplest sum‑of‑products form or to prove equivalence. Work stepwise, annotating each transformation.
OCR 要求运用代数定律化简:交换律、结合律、分配律、同一律、互补律、幂等律、吸收律以及德摩根律。目标是将给定表达式化为最简的“与或式”或证明等价性。按步骤化简,每一步注明所使用的定律。
Simplify: ¬(A ∨ ¬B) ∧ (A ∨ B). First apply De Morgan: ¬(A ∨ ¬B) = ¬A ∧ B. Then expression = (¬A ∧ B) ∧ (A ∨ B) = (¬A ∧ B ∧ A) ∨ (¬A ∧ B ∧ B). ¬A ∧ A = 0, so left term vanishes. Right term: ¬A ∧ B (since B∧B=B). Final answer: ¬A ∧ B. In an exam, you may need to complete a simplification table with justification.
化简:¬(A ∨ ¬B) ∧ (A ∨ B)。先用德摩根律:¬(A ∨ ¬B) = ¬A ∧ B。则表达式 = (¬A ∧ B) ∧ (A ∨ B) = (¬A ∧ B ∧ A) ∨ (¬A ∧ B ∧ B)。¬A ∧ A = 0,左边项消失。右边项:¬A ∧ B(因为 B∧B=B)。最终结果:¬A ∧ B。考试中可能需要填写带理由的化简表格。
7. File Size and Data Transmission Calculations | 文件大小与数据传输计算
Predictable calculation: image size = width × height × colour depth; sound file size = sample rate × bit depth × duration × channels. Always check units: bits, bytes, kibibytes (KiB = 2¹⁰ bytes), etc. OCR may also ask for download time = file size / bit rate, with consistent units.
可预见的计算:图像大小 = 宽度 × 高度 × 色深;声音文件大小 = 采样率 × 采样深度 × 时长 × 声道数。始终检查单位:位、字节、千比字节(KiB = 2¹⁰ 字节)等。OCR 也可能要求:下载时间 = 文件大小 / 比特率,单位要保持一致。
Example: A 10‑second stereo audio sampled at 44.1 kHz with 16‑bit resolution. Size per second = 44100 × 16 × 2 = 1,411,200 bits = 176,400 bytes. For 10 seconds = 1,764,000 bytes ≈ 1682 KiB (since 1 KiB = 1024 B). Show working clearly; OCR expects you to convert correctly between binary and decimal prefixes.
示例:一段 10 秒立体声音频,采样率 44.1 kHz,分辨率 16 位。每秒大小 = 44100 × 16 × 2 = 1,411,200 位 = 176,400 字节。10 秒则为 1,764,000 字节 ≈ 1682 KiB(因 1 KiB = 1024 B)。答题须展示清晰步骤;OCR 要求正确换算二进制与十进制前缀。
8. CPU Performance and Pipeline Calculation | CPU 性能与流水线计算
Use the formula: execution time = instruction count × CPI × clock cycle time, where cycle time = 1 / frequency. For a pipelined processor, ideal speedup equals number of pipeline stages, though stalls reduce this. OCR might provide a table of instruction types and CPIs; calculate average CPI and total time.
使用公式:执行时间 = 指令数 × CPI × 时钟周期时间,其中周期时间 = 1 / 频率。对于流水线处理器,理想加速比等于流水线段数,但停顿会降低此值。OCR 可能给出指令类型及其 CPI 表格,要求计算平均 CPI 和总时间。
Given: 200 million instructions, clock 2 GHz. 40% of instructions CPI=1, 30% CPI=2, 30% CPI=3. Average CPI = 0.4×1 + 0.3×2 + 0.3×3 = 1.9. Cycle time = 1/(2×10⁹) = 0.5 ns. Execution time = 200×10⁶ × 1.9 × 0.5×10⁻⁹ = 0.19 seconds. OCR questions may also ask about the effect of doubling clock speed on power consumption.
给定:2 亿条指令,时钟频率 2 GHz。40% 指令 CPI=1,30% CPI=2,30% CPI=3。平均 CPI = 0.4×1 + 0.3×2 + 0.3×3 = 1.9。周期时间 = 1/(2×10⁹) = 0.5 ns。执行时间 = 200×10⁶ × 1.9 × 0.5×10⁻⁹ = 0.19 秒。OCR 题目也可能问及时钟频率翻倍对功耗的影响。
9. Addressing Modes and Effective Address Calculation | 寻址方式与有效地址计算
For indexed, base‑register, or relative addressing, the effective address is the sum of the given base/index register and the offset (possibly sign‑extended). In immediate addressing, the operand is the value itself. Know how the processor computes the address from the instruction fields.
对于变址、基址寄存器或相对寻址,有效地址是给定的基址/变址寄存器值与偏移量(可能需符号扩展)之和。在立即寻址中,操作数就是值本身。理解处理器如何从指令字段计算出地址。
Example: LDR R1, [R2, #20] in ARM style. R2 contains 0x1000. Effective address = 0x1000 + 20 = 0x1014. If using PC‑relative, EA = PC + offset. OCR may present a diagram with base, index, displacement and ask for the calculated address, then the value loaded.
示例:LDR R1, [R2, #20](类似 ARM 风格)。R2 内容为 0x1000。有效地址 = 0x1000 + 20 = 0x1014。若为 PC 相对寻址,EA = PC + 偏移量。OCR 可能给出包含基址、变址、位移的图示,要求计算地址及加载的值。
10. Hash Table and Collision Resolution Arithmetic | 散列表与碰撞解决计算
Given a hash function, e.g., key mod N, calculate the bucket index. For linear probing, when a collision occurs, insert at the next free slot. You might need to show the state of the table step by step and compute the number of probes to locate a value.
给定散列函数,如 key mod N,计算桶索引。对于线性探测法,发生碰撞时,插入到下一个空闲槽位。你可能需要逐步展示散列表状态,并计算查找某个值所需的探测次数。
Example: hash table size 7, key mod 7. Insert keys 18, 11, 25, 32. 18 mod 7 = 4, place at 4. 11 mod 7 = 4, collision, probe 5 → place 5. 25 mod 7 = 4, probe 5 (taken), 6 → place 6. 32 mod 7 = 4, probe 5,6,0 → place 0. OCR could ask: “How many comparisons needed to search for 32?” or evaluate the load factor = items / size.
示例:散列表大小 7,散列函数 key mod 7。插入键 18, 11, 25, 32。18 mod 7 = 4,存入 4。11 mod 7 = 4,碰撞,探测 5 → 存入 5。25 mod 7 = 4,探测 5(占用)、6 → 存入 6。32 mod 7 = 4,探测 5,6,0 → 存入 0。OCR 可能问:“查找 32 需要多少次比较?”或者计算负载因子 = 项目数 / 大小。
11. Big‑O and Complexity Calculations | 大O表示法与复杂度计算
For nested loops, multiply the iterations. Simple for loops running N times yield O(N); nested loop over N inside another N yields O(N²). For logarithmic, consider a loop dividing the problem size by 2 each time, e.g., binary search is O(log N). Be able to analyze given pseudocode and express time complexity.
对于嵌套循环,将迭代次数相乘。一层循环运行 N 次为 O(N);循环内再嵌套一层 N 次得到 O(N²)。对于对数复杂度,考虑每次迭代将问题规模减半的循环,例如二分查找为 O(log N)。能够分析给定的伪代码并表达时间复杂度。
Example: i = 1; while i < N: i = i * 2. The loop runs log₂N times → O(log N). Another: for i from 1 to N: for j from 1 to i: constant work. Total iterations = 1+2+…+N = N(N+1)/2 → O(N²). OCR includes ranking algorithms by complexity, and selecting the most efficient for large data sets.
示例:i = 1; while i < N: i = i * 2。循环执行 log₂N 次 → O(log N)。另一例:for i 从 1 到 N: for j 从 1 到 i: 常量操作。总迭代次数 = 1+2+…+N = N(N+1)/2 → O(N²)。OCR 包括按复杂度排序算法,以及为大数据集选择最高效算法。
12. Error Detection and Correction Calculations | 错误检测与纠正计算
Parity bit calculation: count number of 1s, add a parity bit to make total even (even parity) or odd. For checksums, compute the sum of data blocks, take the complement or modulo. CRC uses polynomial division on bit patterns. Hamming code (SEC) inserts parity bits at positions that are powers of 2; you may need to locate and correct a single‑bit error.
奇偶校验位计算:统计 1 的个数,添加一个校验位使总数为偶数(偶校验)或奇数。校验和计算数据块之和,再取补码或模。CRC 采用多项式除法处理位模式。汉明码(SEC)在 2 的幂次位置插入校验位;你可能需要定位并纠正单比特错误。
Hamming example: 4‑bit data 1011, with parity bits p1 at pos 1, p2 at pos 2, p4 at pos 4. Positions that contribute to p1 (pos 1,3,5,7): bits at 3=1,5=0,7=1 → XOR=0, so p1=0 for even parity. p2 covers 2,3,6,7: 2=p2,3=1,6=0,7=1 → XOR=0, so p2=0. p4 covers 4,5,6,7: 5=0,6=0,7=1 → XOR=1, p4=1. Codeword: p1 p2 d1 p4 d2 d3 d4 → positions 1–7: 0 0 1 1 0 1 1. OCR might flip a bit and ask to identify the error position using the syndrome.
汉明码示例:4位数据 1011,校验位 p1 在位置1,p2 在位置2,p4 在位置4。参与 p1 的位置(1,3,5,7):位3=1,位5=0,位7=1 → 异或=0,故 p1=0(偶校验)。p2 覆盖位置 2,3,6,7:位3=1,位6=0,位7=1 → 异或=0,p2=0。p4 覆盖 4,5,6,7:位5=0,位6=0,位7=1 → 异或=1,p4=1。码字:位置1–7为 0 0 1 1 0 1 1。OCR 可能翻转某一位,让你用校验子定位错误位置。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导