IB & CIE Computer Science Calculation Drills | IB & CIE 计算机科学计算题专项训练

📚 IB & CIE Computer Science Calculation Drills | IB & CIE 计算机科学计算题专项训练

Calculation-based questions form a significant part of both IB and CIE Computer Science assessments. From number base conversions to processor performance metrics, mastering these numerical skills can boost your exam confidence and secure easy marks. This article provides a collection of focused drills covering the most common calculation topics, with explanations paired in English and Chinese to support bilingual learners. Practice each section systematically and use the worked examples to check your understanding.

计算题在 IB 和 CIE 计算机科学考试中占据重要比重。从数制转换到处理器性能指标,掌握这些数值计算技能可以提升你的考试信心,稳稳拿下这些容易得分的题目。本文提供了一系列专项训练,覆盖了最常见的计算主题,并采用中英双语对照讲解,方便双语学习者使用。请按章节系统地练习,并利用给出的示例来检验自己的理解。

1. Number System Conversions | 数制转换

Converting between binary, denary (decimal) and hexadecimal is a fundamental skill. You must know place values and the symbols A–F for hexadecimal.

二进制、十进制与十六进制之间的转换是基础技能。必须掌握位权值以及十六进制中 A–F 这六个符号的含义。

Key Conversion Methods:

核心转换方法:

  • Binary to Denary: Sum of (digit × 2position) from right starting at 0.

    二进制转十进制: 将每个数位乘以 2 的位权次方,从右起位权从 0 开始,再求和。

  • Denary to Binary: Repeatedly divide by 2 and record remainders from bottom to top.

    十进制转二进制: 反复除以 2,记录余数,从下往上读取。

  • Binary to Hexadecimal: Group into nibbles (4 bits), convert each group.

    二进制转十六进制: 每 4 位分为一组,每组分别转换为对应的十六进制符号。

Example: 10110110₂ → ?₁₀

示例:10110110₂ → ?₁₀

1×2⁷ + 0×2⁶ + 1×2⁵ + 1×2⁴ + 0×2³ + 1×2² + 1×2¹ + 0×2⁰ = 128 + 0 + 32 + 16 + 0 + 4 + 2 + 0 = 182₁₀

1×2⁷ + 0×2⁶ + 1×2⁵ + 1×2⁴ + 0×2³ + 1×2² + 1×2¹ + 0×2⁰ = 128 + 0 + 32 + 16 + 0 + 4 + 2 + 0 = 182₁₀


2. Binary Arithmetic | 二进制算术

Addition and subtraction in binary use rules similar to decimal, with ‘carry’ at 2 and ‘borrow’ from 2. Multiplication is repeated addition and shifting.

二进制加减法遵循类似十进制的规则,逢 2 进位、借 1 当 2。乘法通常转化为加法和移位操作。

1011₂ + 1101₂

1011₂ + 1101₂

Align columns: 1011 (11₁₀) + 1101 (13₁₀) = 11000₂ (24₁₀). Carry at each column where 1+1 occurs.

按列对齐相加:1011 (11₁₀) + 1101 (13₁₀) = 11000₂ (24₁₀)。每逢 1+1 便向上一位进 1。


3. Two’s Complement Negative Numbers | 二进制补码表示负数

Two’s complement is used to represent signed integers. The most significant bit (MSB) indicates the sign. To negate a number, invert all bits and add 1.

补码用于表示有符号整数,最高位为符号位。对一个数取负值的方法为:所有位取反后再加 1。

Find –6 in 8-bit two’s complement.

求 –6 的 8 位补码形式。

+6 = 00000110. Invert → 11111001, add 1 → 11111010. So –6 = 11111010₂.

+6 = 00000110。取反 → 11111001,加 1 → 11111010。因此 –6 表示为 11111010₂。


4. Floating Point Representation | 浮点数表示

IB and CIE syllabi may include converting a binary floating point number (mantissa and exponent) to denary. The mantissa is a signed fixed-point number, and the exponent is a two’s complement integer that shifts the point.

IB 与 CIE 大纲要求理解浮点数的二进制表示(尾数与阶码)转换为十进制。尾数为带符号的定点小数,阶码为补码整数,负责移动小数点。

Formula: Value = mantissa × 2exponent

公式: 数值 = 尾数 × 2阶码

Given an 8-bit mantissa 01010000 (0.0101000₂) and exponent 000010 (+2), the point shifts right by 2 places, giving 1.01000₂ = 1.25₁₀.

若 8 位尾数为 01010000 (即0.0101000₂),阶码为 000010 (+2),则小数点右移 2 位,得到 1.01000₂ = 1.25₁₀。


5. Logic Gate Calculations & Truth Tables | 逻辑门计算与真值表

Build truth tables for circuits with AND, OR, NOT, NAND, NOR, XOR gates. Calculate output column by column, following gate precedence.

为包含与、或、非、与非、或非、异或门的电路建立真值表。按照逻辑门优先级,逐列计算输出值。

Q = (A AND B) OR (NOT C)

Q = (A AND B) OR (NOT C)

A B C A AND B NOT C Q
0 0 0 0 1 1
0 0 1 0 0 0
0 1 0 0 1 1
0 1 1 0 0 0
1 0 0 0 1 1
1 0 1 0 0 0
1 1 0 1 1 1
1 1 1 1 0 1

6. Simplifying Boolean Expressions | 布尔表达式化简

Apply Boolean laws (commutative, associative, distributive, De Morgan’s) to minimise logic circuits. Exam questions may ask for simplification and a resulting circuit diagram.

运用布尔代数定律(交换律、结合律、分配律、德摩根定律等)化简逻辑电路。考题可能要求化简表达式并画出简化后的电路图。

Prove: (A.B)‾ = A‾ + B‾

求证:(A·B)‾ = A‾ + B‾

This is De Morgan’s law. Using truth tables or algebraic manipulation, you can verify both sides yield identical output for all input combinations.

这是德摩根定律。利用真值表或代数推导,可以验证等式两边在所有输入组合下输出一致。


7. Memory and File Size Calculations | 存储器与文件大小计算

Calculate storage required for text, images, and sound. Remember: 1 byte = 8 bits, 1 KB = 1024 bytes (in many exam contexts), though some specifications may use 1000 for simplified transfer rates; check your syllabus.

计算文本、图像和音频所需的存储空间。注意:1 字节 = 8 位,1 KB 通常为 1024 字节(很多考试沿用此约定),但部分数据传输率使用 1000,需根据考纲确定。

Text: bytes = number of characters (assuming ASCII, 1 byte each; Unicode may use 2–4 bytes).

文本: 字节数 = 字符数(若为 ASCII 每字符 1 字节;Unicode 可能使用 2–4 字节)。

Image: size in bits = width × height × colour depth. Convert to bytes by dividing by 8.

图像: 大小(位)= 宽度 × 高度 × 颜色深度。除以 8 转换为字节数。

Sound: file size in bits = sample rate × bit depth × duration (seconds) × number of channels.

音频: 文件大小(位)= 采样频率 × 位深度 × 时长(秒)× 声道数。


8. Data Transmission Time & Bandwidth | 数据传输时间与带宽

Time to transfer = file size ÷ transfer rate. Ensure units match: if file size is in megabits and rate in Mbps, time is in seconds. Bit rate = baud rate × bits per symbol.

传输时间 = 文件大小 ÷ 传输速率。务必统一单位:若文件大小以兆位计、速率以 Mbps 计,则时间为秒。比特率 = 波特率 × 每符号位数。

Download a 50 MB file over a 20 Mbps connection. Time = ?

通过 20 Mbps 连接下载 50 MB 文件,耗时多久?

50 MB = 50 × 8 = 400 Mb. Time = 400 Mb ÷ 20 Mbps = 20 seconds. (Note: if using 1 MB = 1024 KB, adjust accordingly; commonly exam data will specify if 1000 or 1024 conversion is needed.)

50 MB = 50 × 8 = 400 Mb。时间 = 400 Mb ÷ 20 Mbps = 20 秒。(注意:若 1 MB = 1024 KB 需调整;考试通常会指明使用 1000 还是 1024 换算。)


9. Processor Performance Metrics | 处理器性能指标

Key formulas: Execution Time = (Number of Instructions × CPI) ÷ Clock Rate, where CPI is Clocks Per Instruction. MIPS = Clock Rate (in MHz) ÷ CPI.

关键公式:执行时间 = (指令数 × CPI) ÷ 时钟频率,其中 CPI 为每条指令所需时钟周期数。MIPS = 时钟频率 (MHz) ÷ CPI。

A CPU runs at 2 GHz, CPI = 1.5. Execute 6 × 10⁹ instructions. Find time.

某 CPU 主频 2 GHz,CPI = 1.5,执行 6 × 10⁹ 条指令,求执行时间。

Clock cycles = 6e9 × 1.5 = 9 × 10⁹ cycles. Time = 9e9 ÷ 2e9 Hz = 4.5 seconds.

时钟周期数 = 6×10⁹ × 1.5 = 9×10⁹。时间 = 9×10⁹ ÷ 2×10⁹ Hz = 4.5 秒。


10. Pipelining Throughput | 流水线吞吐率

For an ideal k-stage pipeline with n instructions, execution time = (k + n – 1) × clock cycle time. Throughput = n ÷ total time.

对于 k 级理想流水线,处理 n 条指令的执行时间 = (k + n – 1) × 时钟周期。吞吐率 = n ÷ 总时间。

5-stage pipeline, cycle time 2 ns, 100 instructions. Throughput?

5 级流水线,时钟周期 2 ns,100 条指令。吞吐率?

Total time = (5 + 100 – 1) × 2 ns = 104 × 2 = 208 ns. Throughput = 100 / 208 ns ≈ 0.48 instructions/ns or 480 MIPS.

总时间 = (5 + 100 – 1) × 2 ns = 104 × 2 = 208 ns。吞吐率 = 100 / 208 ns ≈ 0.48 指令/ns,即 480 MIPS。


11. Big O Notation of Simple Algorithms | 简单算法的时间复杂度

Derive Big O by counting loop executions. A single loop up to n yields O(n). Nested loops with independent counters yield O(n²). Binary search halves the search space, giving O(log n).

通过统计循环执行次数推导时间复杂度。单层循环上至 n 时为 O(n)。嵌套独立计数器循环为 O(n²)。二分查找每次将搜索空间减半,时间复杂度为 O(log n)。

for i = 0 to n–1: for j = 0 to n–1: print i*j

for i = 0 to n–1: for j = 0 to n–1: print i*j

The inner loop runs n times for each of the n outer iterations, total steps = n × n → O(n²).

内层循环在外层每次迭代中运行 n 次,总步骤为 n × n → O(n²)。


12. Checksum and Hamming Code Calculations | 校验和与汉明码计算

Checksum: sum data bytes (carrying overflow back) and take the one’s complement. Hamming codes require placing parity bits at positions 1,2,4,8… and calculating parity for appropriate groups.

校验和:将数据字节求和(将溢出进位加回)后取反码。汉明码需要在 1,2,4,8… 位置放置校验位,并按相应分组计算奇偶性。

Simple Checksum Example: bytes 11001010, 00101101. Sum = 11110111 + carry 0 → checksum = one’s complement = 00001000.

简单校验和示例: 字节 11001010 与 00101101 相加得 11110111,无进位,取反码得校验和 00001000。

Hamming (7,4) example: data bits D3 D5 D6 D7 (positions 3,5,6,7). Compute P1 for positions 1,3,5,7 etc. This builds error correction capability.

汉明码 (7,4) 示例: 数据位放在 3,5,6,7 位。P1 校验 1,3,5,7 位上的数值奇偶性,依此类推,可实现单错纠正。


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