📚 A-Level OCR Computer Science: Calculation Skills Drill | A-Level OCR 计算机:计算题专项训练
Calculation problems form a core part of OCR A-Level Computer Science (H446). From number representation and file sizes to Boolean simplification and subnetting, you must be fluent in numeric reasoning. This drill covers the most commonly tested calculation areas, with step-by-step examples in both English and Chinese.
计算题是 OCR A-Level 计算机科学 (H446) 的核心组成部分。无论是数字表示、文件大小计算,还是布尔化简与子网划分,都需要扎实的数值推理能力。本专项训练覆盖最常出现的大纲计算题型,每个题型都配有中英双语分步示例。
1. Number System Conversions & Binary Arithmetic | 进制转换与二进制算术
Master denary, binary and hexadecimal interconversions. For binary addition, align bits and carry over. Overflow occurs when the result cannot be represented within the given bit width (e.g., two 8-bit two’s complement numbers produce a 9-bit result).
掌握十进制、二进制和十六进制之间的互转。二进制加法时,按位对齐并进位。当结果超出给定位宽所能表示的范围(例如两个 8 位二进制补码数相加产生 9 位结果)时,会发生溢出。
Example: Convert 202₁₀ to binary and hex. 202 = 128 + 64 + 8 + 2 → 1100 1010₂ → CA₁₆.
示例:将 202₁₀ 转为二进制和十六进制。202 = 128 + 64 + 8 + 2 → 1100 1010₂ → CA₁₆。
2. Two’s Complement Representation & Range | 二进制补码表示与范围
In an n-bit two’s complement system, the most significant bit (MSB) indicates sign. Range is –2ⁿ⁻¹ to 2ⁿ⁻¹ – 1. To negate a number, flip all bits and add 1.
在 n 位二进制补码系统中,最高有效位 (MSB) 表示符号。表示范围为 –2ⁿ⁻¹ 到 2ⁿ⁻¹ – 1。对数值取负的操作为:所有位取反后加 1。
Example: Represent –18 in 8-bit two’s complement. +18 = 0001 0010₂, flip → 1110 1101, add 1 → 1110 1110₂.
示例:用 8 位补码表示 –18。+18 = 0001 0010₂,取反 → 1110 1101,加 1 → 1110 1110₂。
The range for 8-bit two’s complement is –128 to +127. Any result outside this causes overflow.
8 位补码的表示范围是 –128 到 +127。超出该范围会导致溢出。
3. Floating Point Binary | 二进制浮点数
OCR uses two’s complement for both mantissa and exponent. A normalised floating-point number has mantissa with a different sign bit to the first fractional bit (i.e., 0.1… for positive, 1.0… for negative). The decimal value = mantissa × 2exponent.
OCR 大纲对尾数和阶码都采用二进制补码。规格化浮点数要求尾数符号位与第一位小数位不同(正数为 0.1…,负数为 1.0…)。十进制值 = 尾数 × 2阶码。
Example: Represent 6.5 with 8-bit mantissa and 4-bit exponent. 6.5 = 110.1₂ = 0.1101 × 2³. Exponent = 3 = 0011. Mantissa = 0.1101000 (8 bits). Normalised: 0110 1000 0011.
示例:用 8 位尾数、4 位阶码表示 6.5。6.5 = 110.1₂ = 0.1101 × 2³。阶码 = 3 = 0011。8 位尾数 0.1101000。规格化浮点数:0110 1000 0011。
4. Image and Sound File Size Calculations | 图像与声音文件大小计算
Image file size (bits) = width × height × colour depth. To convert to bytes: divide by 8. Remember that colour depth = bits per pixel, e.g., 24-bit true colour.
图像文件大小(比特) = 宽度 × 高度 × 颜色深度。转换为字节需除以 8。颜色深度即每像素位数,例如 24 位真彩色。
Sound file size (bits) = sample rate × bit depth × duration (seconds) × number of channels. Be careful to match units.
声音文件大小(比特) = 采样率 × 位深 × 时长(秒) × 声道数。注意单位统一。
Image bits = width × height × colour depth
Sound bits = sample rate × bit depth × seconds × channels
5. Data Compression Calculations | 数据压缩计算
Run-length encoding (RLE) can be quantified by counting the total number of runs. For a sequence, the compressed size = number of runs × (data size + count size). A compression ratio = original size / compressed size.
游程编码 (RLE) 可通过统计游程数来量化。压缩后大小 = 游程数 × (数据大小 + 计数大小)。压缩比 = 原始大小 / 压缩后大小。
Huffman coding: given symbol frequencies, build the tree and assign variable-length codes. The total bits = Σ (frequency × code length). Calculate compression ratio against fixed-length encoding.
哈夫曼编码:根据符号频率构建哈夫曼树,分配变长码字。总位数 = Σ (频率 × 码长)。计算对比定长编码的压缩比。
Example: Symbols A:15, B:7, C:6, D:3. Fixed-length: 2 bits each → total 62 bits. Huffman codes: A:0, B:10, C:110, D:111 → total = 15×1 + 7×2 + 6×3 + 3×3 = 56 bits. Compression ratio = 62/56 ≈ 1.11.
示例:符号频率 A:15, B:7, C:6, D:3。定长编码每符号 2 位 → 共 62 位。哈夫曼编码:A:0, B:10, C:110, D:111 → 总位数 = 15×1 + 7×2 + 6×3 + 3×3 = 56 位。压缩比约 1.11。
6. Karnaugh Maps & Boolean Simplification | 卡诺图与布尔表达式化简
For up to 4 variables, fill the K-map with 1s corresponding to minterms. Group adjacent 1s in powers of two (1,2,4,8). Each group gives a product term. The simplified expression is the sum of these products.
最多 4 个变量的布尔函数,将最小项对应的 1 填入卡诺图。以 2 的幂次(1,2,4,8)圈组相邻的 1。每个圈组给出一个乘积项,最简表达式为这些乘积项之和。
Example: F(A,B,C) = Σ(1,2,5,6,7). 3-variable K-map groups: blue group (m5,m7,m1,m3 but m3 not present so only m5,m7,m1? Actually need to show grouping. Provide final: F = A’B’C + A’BC’ + AB’C + ABC’ + ABC. After K-map: groups: (m5,m7) gives AC; (m2,m6) gives BC’; (m1,m5) gives B’C. So simplified F = AC + BC’ + B’C. Write as step.
示例:F(A,B,C) = Σ(1,2,5,6,7)。画 3 变量卡诺图,圈组后得到 F = AC + BC’ + B’C。
7. Logic Gate & Truth Table Problem Solving | 逻辑门与真值表综合计算
Given a logic diagram, derive the Boolean expression and complete the truth table. You can then simplify the expression algebraically and calculate the number of gates required.
给出逻辑电路图,要求推导布尔表达式并填写真值表。之后可进行代数化简,计算所需门电路数量。
For instance, a circuit with AND, OR, NOT: X = (A AND B) OR (NOT C). Truth table has 2³ = 8 rows. Count the gates: one AND, one NOT, one OR → 3 gates.
例如,一个包含与、或、非门的电路:X = (A AND B) OR (NOT C)。真值表有 8 行。门数统计:1 个与门、1 个非门、1 个或门,共 3 个门。
8. Subnet Mask and IP Addressing | 子网掩码与 IP 寻址
Given an IP address and a slash notation (e.g., 192.168.1.0/26), calculate the subnet mask, number of subnets, and number of usable host addresses per subnet. The formula for hosts = 2(32 – prefix length) – 2 (subtract network and broadcast addresses).
给定 IP 地址和斜杠记法(如 192.168.1.0/26),计算子网掩码、子网数量以及每子网可用主机地址数。主机数公式 = 2(32 – 前缀长度) – 2(减去网络地址和广播地址)。
Example: /26 → subnet mask 255.255.255.192. Total addresses = 26 = 64; usable = 62. Subnet increment = 64; subnet address = first address of block; broadcast = last address.
示例:/26 → 子网掩码 255.255.255.192。总地址数 64,可用 62。子网增量 64,子网地址为块内首地址,广播地址为末地址。
9. CPU Performance Calculations | CPU 性能计算
Execution time for a program can be calculated using: Time = (Number of instructions × CPI) / Clock frequency. CPI = cycles per instruction. You may also calculate MIPS (millions of instructions per second).
程序执行时间公式:时间 = (指令数量 × CPI) / 时钟频率。CPI 表示每条指令所需时钟周期数。也需会计算 MIPS(每秒百万条指令)。
Execution Time = (Instruction Count × CPI) / Clock Rate
MIPS = Clock Rate / (CPI × 10⁶)
Example: A program has 2 × 10⁷ instructions, average CPI = 1.5, and the CPU clock is 2 GHz. Time = (2×10⁷ × 1.5) / (2×10⁹) = 0.015 s = 15 ms.
示例:程序含 2×10⁷ 条指令,平均 CPI = 1.5,CPU 主频 2 GHz。时间 = (2×10⁷ × 1.5) / (2×10⁹) = 0.015 秒 = 15 毫秒。
10. Checksum and Parity Calculations | 校验和与奇偶校验计算
A simple checksum is obtained by adding bytes (modulo 256) and taking the two’s complement of the sum. Parity bit is set so that the total number of 1s (including parity) is even (even parity) or odd (odd parity).
简单校验和通过将各字节相加(模 256),然后对和值取二进制补码得到。奇偶校验位设置为使包括校验位在内的 1 的个数为偶数(偶校验)或奇数(奇校验)。
Example: Data bytes 0x48, 0x65, 0x6C. Sum = 0x48+0x65+0x6C = 0x119. Modulo 256 → 0x19. Two’s complement → 0xE7. Checksum byte = 0xE7. Even parity for 0x48 (0100 1000) has three 1s → parity bit = 1 to make four 1s (even).
示例:数据字节 0x48, 0x65, 0x6C。相加得 0x119,模 256 得 0x19,补码后为 0xE7。校验字节 0xE7。0x48 的偶校验:已有 3 个 1,校验位设 1 得到偶数 4 个 1。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply