📚 IB CCEA Computer Science: Calculation Problem Drill | IB CCEA 计算机科学:计算题专项训练
Mastering numerical calculations is essential for success in both IB Computer Science and CCEA GCE Digital Technology. This article provides a targeted drill covering the most common calculation-based problems that appear across these syllabuses, from binary arithmetic to storage estimation and network latency.
掌握数值计算对于在 IB 计算机科学和 CCEA GCE 数字技术考试中取得成功至关重要。本文提供了一份专项训练,涵盖了这些课程大纲中最常见的计算类题目,从二进制算术到存储估算和网络延迟计算。
1. Number System Conversions | 数制转换
Convert the binary number 1011 0110₂ to its denary, hexadecimal, and octal equivalents. Remember to group bits from the right for hexadecimal (4 bits per group) and octal (3 bits per group).
将二进制数 1011 0110₂ 转换为十进制、十六进制和八进制。注意从右端开始为十六进制(每 4 位一组)和八进制(每 3 位一组)进行分组。
For denary, calculate: (1×2⁷) + (0×2⁶) + (1×2⁵) + (1×2⁴) + (0×2³) + (1×2²) + (1×2¹) + (0×2⁰) = 128 + 32 + 16 + 4 + 2 = 182. For hexadecimal, group as 1011 0110 → B6₁₆. For octal, group as 10 110 110 → 266₈.
十进制计算: (1×2⁷) + (0×2⁶) + (1×2⁵) + (1×2⁴) + (0×2³) + (1×2²) + (1×2¹) + (0×2⁰) = 128 + 32 + 16 + 4 + 2 = 182。十六进制分组 1011 0110 → B6₁₆。八进制分组 10 110 110 → 266₈。
When converting decimal fractions to binary, multiply the fractional part by 2 repeatedly, recording the integer parts until you reach zero or the required precision.
在将十进制小数转换为二进制时,反复将小数部分乘以 2,记录整数部分,直到达到零或所需精度。
2. Binary Arithmetic and Overflow | 二进制算术与溢出
Add the 8-bit two’s complement numbers 0101 1100 and 0010 1011. Then combine 1100 1010 and 1010 0111 and determine if overflow occurs.
将 8 位二进制补码数 0101 1100 和 0010 1011 相加。再将 1100 1010 与 1010 0111 相加,并判断是否发生溢出。
First addition: 0101 1100 + 0010 1011 = 1000 0111. Since we are adding two positive numbers and the result has a 1 in the most significant bit, overflow has occurred (the correct sum, 135, exceeds +127 in two’s complement). Second addition: 1100 1010 + 1010 0111 = 1 0111 0001, discard carry out, result is 0111 0001. Here two negative numbers added yielded a positive result, indicating overflow.
第一次加法:0101 1100 + 0010 1011 = 1000 0111。由于我们相加的是两个正数,而结果的最高位为 1,发生了溢出(正确和 135 超过了补码表示范围 +127)。第二次加法:1100 1010 + 1010 0111 = 1 0111 0001,丢弃进位,结果为 0111 0001。此处两个负数相加产生正数结果,表明溢出。
| Operation | 8-bit two’s complement range: -128 to +127 |
| 0101 1100 (92) + 0010 1011 (43) | Result 1000 0111 (-121) → Overflow |
| 1100 1010 (-54) + 1010 0111 (-89) | Result 0111 0001 (113) → Overflow |
3. Logic Gate Combinations and Truth Table Analysis | 逻辑门组合与真值表分析
For the logic circuit A AND (B OR (NOT C)), write the full truth table and identify a simpler Boolean expression that produces the same output. This is a typical simplification task in both IB and CCEA exams.
对于逻辑电路 A AND (B OR (NOT C)),写出完整的真值表,并找出产生相同输出的简化布尔表达式。这是 IB 和 CCEA 考试中典型的化简题型。
Construct columns for A, B, C, NOT C, B OR (NOT C), and final X. After completing the table, you will see X = A AND (B OR NOT C). Applying Boolean laws, this expression cannot be reduced to a single gate, but it demonstrates how to derive a truth table from a circuit diagram.
为 A、B、C、NOT C、B OR (NOT C) 以及最终 X 建立列。完成真值表后,你将看到 X = A AND (B OR NOT C)。运用布尔定律,此式无法简化为单门结构,但它展示了如何从电路图推导真值表。
| A | B | C | NOT C | B OR NOT C | X |
| 0 | 0 | 0 | 1 | 1 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 1 | 1 |
4. Storage Unit Conversions and Data Transfer Rates | 存储单位换算与数据传输速率
Given a 4 GiB memory card, calculate how many 3.5 MiB music files can be stored. Always align units before dividing and remember the difference between binary and decimal prefixes.
给定一个 4 GiB 的存储卡,计算可以存放多少个 3.5 MiB 的音乐文件。计算前务必将单位对齐,并牢记二进制前缀与十进制前缀的区别。
4 GiB = 4 × 2³⁰ bytes. 3.5 MiB = 3.5 × 2²⁰ bytes. Number of files = (4 × 2³⁰) / (3.5 × 2²⁰) = (4/3.5) × 2¹⁰ ≈ 1.1428 × 1024 ≈ 1170. So approximately 1170 files can be stored.
4 GiB = 4 × 2³⁰ 字节。3.5 MiB = 3.5 × 2²⁰ 字节。文件数 = (4 × 2³⁰) / (3.5 × 2²⁰) = (4/3.5) × 2¹⁰ ≈ 1.1428 × 1024 ≈ 1170。因此约可存储 1170 个文件。
CCEA questions often require conversion between bits and bytes for network transfer: a 100 Mbps connection sends 100 × 10⁶ bits per second. To transfer a 25 MB file, time = (25 × 8 × 10⁶) / (100 × 10⁶) = 2 seconds.
CCEA 考题常涉及网络传输的比特与字节换算:一条 100 Mbps 的连接每秒发送 100 × 10⁶ 比特。传输一个 25 MB 的文件,时间 = (25 × 8 × 10⁶) / (100 × 10⁶) = 2 秒。
5. Sampling and Bitmap Image File Size Calculation | 采样与位图图像文件大小计算
A bitmap image has dimensions 1920 × 1080 pixels and uses a 24-bit colour depth. Calculate its uncompressed file size in MiB. This tests the formula: width × height × bit depth.
一张位图尺寸为 1920 × 1080 像素,采用 24 位色深。计算其未压缩文件大小(以 MiB 为单位)。这考查公式:宽度 × 高度 × 色深。
Total bits = 1920 × 1080 × 24 = 49,766,400 bits. Convert to bytes: 49,766,400 / 8 = 6,220,800 bytes. Convert to MiB: 6,220,800 / (2²⁰) ≈ 6,220,800 / 1,048,576 ≈ 5.93 MiB. In exams, you may be asked to express the size in KiB or MB (decimal).
总比特数 = 1920 × 1080 × 24 = 49,766,400 比特。转换为字节:49,766,400 / 8 = 6,220,800 字节。转换为 MiB:6,220,800 / (2²⁰) ≈ 6,220,800 / 1,048,576 ≈ 5.93 MiB。考试中可能要求以 KiB 或 MB(十进制)表示。
6. Audio File Size Estimation | 音频文件大小估算
Estimate the size of a 3-minute stereo audio recorded at a sample rate of 44.1 kHz with a bit depth of 16 bits per sample. Use the formula: duration × sample rate × bit depth × channels.
估算一段 3 分钟的立体声音频文件大小,采样率为 44.1 kHz,每个样本 16 位。使用公式:时长 × 采样率 × 位深 × 声道数。
Duration in seconds = 3 × 60 = 180 s. Sample rate 44,100 Hz. Total bits = 180 × 44,100 × 16 × 2 = 180 × 44,100 × 32 = 254,016,000 bits. In MB (using 1 MB = 1,000,000 bytes): 254,016,000 / 8 = 31,752,000 bytes → 31.75 MB. In MiB: ≈ 30.28 MiB. Pay close attention to rounding and units required by the mark scheme.
时长以秒计 = 3 × 60 = 180 秒。采样率 44,100 Hz。总比特数 = 180 × 44,100 × 16 × 2 = 180 × 44,100 × 32 = 254,016,000 比特。以 MB(1 MB = 1,000,000 字节)计:254,016,000 / 8 = 31,752,000 字节 → 31.75 MB。以 MiB 计:约 30.28 MiB。务必注意阅卷方案所要求的四舍五入和单位。
7. Network Latency and Bandwidth-Delay Product | 网络延迟与带宽延迟积
For a satellite link with a one-way latency of 240 ms and a bandwidth of 2 Mbps, calculate the bandwidth-delay product and explain what it represents. IB papers often link this to TCP window sizes and throughput.
对于一条单程延迟为 240 ms、带宽为 2 Mbps 的卫星链路,计算带宽延迟积,并解释其含义。IB 试卷常将其与 TCP 窗口大小和吞吐量相联系。
Bandwidth-delay product = bandwidth × round-trip time (RTT). RTT = 2 × 240 ms = 0.48 s. Bandwidth = 2 × 10⁶ bps. Product = 2 × 10⁶ × 0.48 = 960,000 bits. This is the amount of data ‘in flight’ before an acknowledgement can be received; it represents the minimum TCP congestion window needed to fully utilise the link.
带宽延迟积 = 带宽 × 往返时间(RTT)。RTT = 2 × 240 ms = 0.48 s。带宽 = 2 × 10⁶ bps。积 = 2 × 10⁶ × 0.48 = 960,000 比特。这是在收到确认前“在途中”的数据量;它代表了完全利用该链路所需的最小 TCP 拥塞窗口大小。
8. Compression Ratio and Huffman Coding Efficiency | 压缩比与哈夫曼编码效率
In lossless compression problems, you may be given character frequencies and asked to calculate the average code length and compression ratio. Given frequencies A:50%, B:25%, C:12.5%, D:12.5%, build a Huffman tree and compute the metric.
在无损压缩问题中,可能会给出字符频率,要求计算平均码长和压缩比。给定频率 A:50%, B:25%, C:12.5%, D:12.5%,构建哈夫曼树并计算相关指标。
Optimal Huffman codes: A=0, B=10, C=110, D=111. Average code length = (0.5×1) + (0.25×2) + (0.125×3) + (0.125×3) = 0.5 + 0.5 + 0.375 + 0.375 = 1.75 bits per character. Original fixed-length would require 2 bits per character, so compression ratio = original size / compressed size = 2 / 1.75 ≈ 1.14.
最优哈夫曼编码:A=0, B=10, C=110, D=111。平均码长 = (0.5×1) + (0.25×2) + (0.125×3) + (0.125×3) = 1.75 比特每字符。原固定长度需要 2 比特每字符,因此压缩比 = 原始大小 / 压缩后大小 = 2 / 1.75 ≈ 1.14。
9. Checksum and Parity Bit Calculations | 校验和与奇偶校验位计算
Calculate the even parity bit for the 7-bit ASCII character ‘K’ (binary 1001011). Then compute the simple checksum (byte sum modulo 256) for the word ‘CAT’ using ASCII values.
计算 7 位 ASCII 字符 ‘K’(二进制 1001011)的偶校验位。然后使用 ASCII 值计算单词 ‘CAT’ 的简单校验和(字节和模 256)。
Even parity bit: count the number of 1s in 1001011 → 4, which is even, so the parity bit is 0 to keep the parity even. Thus the 8-bit code with parity is 01001011 or 10010110 depending on position. Checksum: ‘C’=67, ‘A’=65, ‘T’=84. Sum = 67+65+84 = 216. Modulo 256 checksum is 216. If an 8-bit one’s complement checksum is required, take the bitwise complement of 216 (in 8 bits) = 256 – 1 – 216 = 39.
偶校验位:1001011 中 1 的个数 = 4,为偶数,因此校验位设为 0 以保持偶校验。因此含校验位的 8 位码可为 01001011 或 10010110(取决于位置)。校验和:’C’=67, ‘A’=65, ‘T’=84。总和 = 216。模 256 校验和为 216。若要求 8 位反码校验和,则取 216 的按位取反(8 位)= 256 – 1 – 216 = 39。
10. Floating Point Precision and Absolute Error | 浮点数精度与绝对误差
Convert 0.2 to a binary floating point representation with 4 bits for the mantissa (normalised) and 3 bits for the exponent (excess-3), and calculate the absolute error. This combines binary fractions and precision limits.
将 0.2 转换为二进制浮点表示,尾数 4 位(规格化),指数 3 位(偏移 3),并计算绝对误差。这综合了二进制分数和精度限制。
0.2 in binary: 0.001100110011… recurring. With only 4 mantissa bits after normalisation, we shift the point: 0.0011 × 2⁰ = 0.1100 × 2⁻². Exponent -2 in excess-3 is 1 (binary 001). Mantissa 0.1100 (leading 1 implicit?). Assuming normalised form with implicit leading 1, the mantissa stored is .1100, representing 1.1100₂ × 2⁻² = (1 + 0.5 + 0.25) × 0.25 = 1.75 × 0.25 = 0.4375. Wait, this isn’t 0.2. Actually, 0.2 = 1.100110011… × 2⁻³. With 4 mantissa bits: .1001 (after truncation) gives 1.1001 × 2⁻³ = (1 + 0.5 + 0.0625) × 0.125 = 1.5625 × 0.125 = 0.1953125. Absolute error = |0.2 – 0.1953125| = 0.0046875. Such problems sharpen your understanding of rounding and truncation errors.
0.2 的二进制表示为 0.001100110011… 循环小数。尾数仅 4 位,规格化后移动小数点:0.0011 × 2⁰ = 0.1100 × 2⁻²。若采用隐式前导 1 的规格化形式,0.2 实际为 1.100110011… × 2⁻³。存储尾数为 4 位(截断)为 .1001,表示 1.1001 × 2⁻³ = (1 + 0.5 + 0.0625) × 0.125 = 1.5625 × 0.125 = 0.1953125。绝对误差 = |0.2 – 0.1953125| = 0.0046875。此类题目能加深你对舍入与截断误差的理解。
11. Algorithm Time Complexity Step Counting | 算法时间复杂度步骤计数
Count the number of elementary operations in a nested loop: for i from 1 to n, for j from 1 to i, sum += 1. IB students must translate such patterns into Big O notation, but first calculate exact counts.
计算嵌套循环中的基本操作次数:for i from 1 to n, for j from 1 to i, sum += 1。IB 学生需要把这种模式转化为大 O 表示,但首先要计算出精确次数。
The innermost statement executes Σ(i=1 to n) Σ(j=1 to i) 1 = Σ(i=1 to n) i = n(n+1)/2 times. This is Θ(n²). If an additional condition like i % 2 == 0 is added, the count halves but the order remains n². Such detailed counting appears in IB Paper 2 algorithms.
最内层语句执行次数为 Σ(i=1 to n) Σ(j=1 to i) 1 = Σ(i=1 to n) i = n(n+1)/2 次。这是 Θ(n²)。如果加入类似 i % 2 == 0 的条件,次数减半,但数量级仍为 n²。这种详细计数会在 IB 卷二算法题中出现。
12. Analogue-to-Digital Converter Resolution | 模数转换器分辨率
Calculate the resolution of an 8-bit ADC with a reference voltage range of 0 to 5 V, and determine the digital output for an input of 2.3 V. Relevant to CCEA Unit 1 and IB computer architecture topics.
计算参考电压范围为 0 至 5 V 的 8 位 ADC 的分辨率,并确定输入电压为 2.3 V 时的数字输出值。与 CCEA 第一单元和 IB 计算机体系结构主题相关。
Resolution = V_ref / 2ⁿ = 5 V / 256 ≈ 0.01953 V. For 2.3 V, the decimal step number = floor(2.3 / 0.01953) ≈ floor(117.76) = 117. Convert 117 to binary: 0111 0101. Thus the ADC outputs 0111 0101. If input were exactly 117.76, quantisation error is 0.76 × 0.01953 ≈ 0.0148 V.
分辨率 = 参考电压 / 2ⁿ = 5 V / 256 ≈ 0.01953 V。对于 2.3 V,量化级数 = floor(2.3 / 0.01953) ≈ floor(117.76) = 117。117 转为二进制:0111 0101。因此 ADC 输出为 0111 0101。若输入恰好为 117.76,量化误差为 0.76 × 0.01953 ≈ 0.0148 V。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导