IB WJEC Computer Science: Calculation Problems Drill | IB WJEC 计算机:计算题专项训练

📚 IB WJEC Computer Science: Calculation Problems Drill | IB WJEC 计算机:计算题专项训练

Calculation problems form a core part of IB and WJEC Computer Science assessments, testing your ability to apply mathematical concepts to computing scenarios. Mastering these techniques is essential for success in both Paper 1 and Paper 2 components. This guide provides intensive practice on common calculation topics, from number systems and Boolean logic to storage, networking, and data representation. Each section breaks down the method, offers worked examples, and challenges you with a practice problem.

计算题是 IB 和 WJEC 计算机科学考试的核心组成部分,考查你将数学概念应用于计算场景的能力。掌握这些技巧对于在试卷一和试卷二中取得成功至关重要。本指南针对常见的计算专题提供强化训练,涵盖数制、布尔逻辑、存储、网络和数据表示。每个小节分解方法、提供详细示例,并用一道练习题挑战你。

1. Binary to Decimal & Decimal to Binary | 二进制与十进制互转

To convert a binary number to decimal, multiply each bit by 2 raised to the power of its position (starting from 0 at the rightmost bit) and sum the results. For example, 10110₂ = 1×2⁴ + 0×2³ + 1×2² + 1×2¹ + 0×2⁰ = 16 + 0 + 4 + 2 + 0 = 22₁₀.

将二进制数转换为十进制,将每一位乘以 2 的位权次方(从最右侧 0 次方开始),并将结果相加。例如,10110₂ = 1×2⁴ + 0×2³ + 1×2² + 1×2¹ + 0×2⁰ = 16 + 0 + 4 + 2 + 0 = 22₁₀。

To convert a decimal integer to binary, repeatedly divide the number by 2 and record the remainders; read the remainders from bottom to top. Convert 45₁₀: 45 ÷ 2 = 22 rem 1, 22 ÷ 2 = 11 rem 0, 11 ÷ 2 = 5 rem 1, 5 ÷ 2 = 2 rem 1, 2 ÷ 2 = 1 rem 0, 1 ÷ 2 = 0 rem 1. Reading upwards gives 101101₂.

将十进制整数转换为二进制,反复除以 2 并记录余数;从下往上读取余数。转换 45₁₀:45 ÷ 2 = 22 余 1,22 ÷ 2 = 11 余 0,11 ÷ 2 = 5 余 1,5 ÷ 2 = 2 余 1,2 ÷ 2 = 1 余 0,1 ÷ 2 = 0 余 1。从下往上得到 101101₂。

Practice: Convert 101011₂ to decimal and 87₁₀ to binary. (Answers: 43₁₀, 1010111₂)

练习:将 101011₂ 转为十进制,将 87₁₀ 转为二进制。(答案:43₁₀,1010111₂)


2. Hexadecimal Conversions | 十六进制转换

Hexadecimal (base‑16) uses digits 0–9 and letters A–F (A=10, B=11, …, F=15). To convert binary to hex, group bits into nibbles (4 bits) starting from the right, then replace each group with its hex equivalent. Example: 10111010₂ becomes 1011 1010, which is B (11) and A (10) → BA₁₆.

十六进制(基数为 16)使用数字 0–9 和字母 A–F(A=10,B=11,……,F=15)。将二进制转为十六进制时,从右开始每四位为一组,然后将每组替换为对应的十六进制数字。例如:10111010₂ 分为 1011 1010,即 B(11)和 A(10)→ BA₁₆。

To convert hex to decimal, multiply each hex digit by 16 raised to the power of its position. For 2F₃₁₆: 2×16¹ + 15×16⁰ = 32 + 15 = 47₁₀.

将十六进制转为十进制,将每位乘以 16 的位权次方。例如 2F₃₁₆:2×16¹ + 15×16⁰ = 32 + 15 = 47₁₀。

Practice: Convert 11011101₂ to hex and A3₁₆ to decimal. (Answers: DD₁₆, 163₁₀)

练习:将 11011101₂ 转为十六进制,将 A3₁₆ 转为十进制。(答案:DD₁₆,163₁₀)


3. Binary Addition and Overflow | 二进制加法与溢出

Binary addition follows similar rules to decimal: 0+0=0, 0+1=1, 1+0=1, 1+1=0 with a carry of 1. When adding two 8‑bit numbers, a carry into the 9th bit indicates an overflow if the result is too large for the allotted bits. For example, 11001010 + 01101101: (column addition) results in 1 00110111 with a carry out of the most significant bit, signalling overflow in unsigned arithmetic.

二进制加法规则与十进制相似:0+0=0,0+1=1,1+0=1,1+1=0 并向高位进 1。当两个 8 位数相加时,若向第 9 位产生进位,且结果超出指定位数,则发生溢出。例如,11001010 + 01101101:(逐列相加)结果为 1 00110111,最高位有进位,表示无符号运算中的溢出。

In two’s complement representation, overflow occurs when the sign bits (the two leftmost carries) are different. Check the carry into the sign bit and the carry out: if they differ, overflow has occurred. Add 01100001 (+97) and 01011010 (+90): carries to sign bit = 1, carry out = 0 → overflow, because the sum should be +187, which exceeds the 8‑bit signed range.

在二进制补码表示中,当符号位的进位(最左侧两次进位)不同时,发生溢出。检查进入符号位的进位与输出进位:若它们不同,则溢出。计算 01100001 (+97) 与 01011010 (+90):进入符号位的进位 = 1,输出进位 = 0 → 溢出,因为和应为 +187,超过了 8 位带符号范围。

Practice: Add 10110011 and 01101010 in unsigned 8‑bit binary. Identify any overflow. (Answer: 1 00011101, overflow occurs.)

练习:在无符号 8 位二进制中将 10110011 与 01101010 相加。判断是否有溢出。(答案:1 00011101,发生溢出。)


4. Boolean Expression Simplification | 布尔表达式化简

Boolean algebra helps simplify logic circuits. Key laws include identity (A+0=A, A·1=A), complement (A+A’=1, A·A’=0), distributive (A·(B+C) = A·B + A·C), and de Morgan ( (A·B)’ = A’ + B’ ). Apply these to reduce expressions and save gates.

布尔代数有助于简化逻辑电路。基本定律包括恒等律(A+0=A,A·1=A)、互补律(A+A’=1,A·A’=0)、分配律(A·(B+C) = A·B + A·C)和德摩根律((A·B)’ = A’ + B’)。运用这些定律可简化表达式并节省门电路。

Example: Simplify F = A·B + A·B’. Factor out A: A·(B + B’) = A·1 = A. Thus the circuit reduces to just a wire.

示例:化简 F = A·B + A·B’。提取公因式 A:A·(B + B’) = A·1 = A。电路因此简化为一条直连线。

Simplify F = (A+B)·(A+B’). Using distributive or consensus: A + (B·B’) = A + 0 = A. Again, no gate needed.

化简 F = (A+B)·(A+B’)。使用分配律或一致律:A + (B·B’) = A + 0 = A。同样无需门电路。

Practice: Simplify F = A·B + A·C + B·C. (Hint: use consensus theorem. Answer: A·B + A·C)

练习:化简 F = A·B + A·C + B·C。(提示:使用一致律。答案:A·B + A·C)


5. Karnaugh Map Minimisation | 卡诺图最小化

A Karnaugh map (K‑map) provides a visual method for simplifying Boolean expressions with up to four variables. Arrange the truth table outputs into a grid where adjacent cells differ by one variable. Group ones in powers of two (1,2,4,8) and derive the minimal sum‑of‑products.

卡诺图(K‑map)为最多四个变量的布尔表达式提供了一种可视化化简方法。将真值表输出填入方格,相邻方格仅有一个变量不同。将1按2的幂次(1,2,4,8)分组,并推导出最简积之和表达式。

Example: For F(A,B) = Σ(0,1,3), the 2‑variable K‑map has ‘1’ in cells 00,01,11. The vertical group covering 00 and 01 gives A’ (since A=0). The pair 01 and 11 gives B. Overlapping groups are allowed. Minimal expression: F = A’ + B.

示例:对于 F(A,B) = Σ(0,1,3),两变量卡诺图在 00、01、11 格中填入1。覆盖 00 和 01 的垂直组给出 A’(因 A=0)。覆盖 01 和 11 的对给出 B。允许组间重叠。最简表达式:F = A’ + B。

For a 3‑variable K‑map (A,B,C), group 1’s into rectangles of 1,2,4. Always try to cover the largest groups first and include all 1’s. Ensure each group contains a power‑of‑two number of cells.

对于三变量卡诺图(A,B,C),将1分组成1、2、4的矩形。始终优先覆盖最大组,并包含所有1。确保每组包含的单元格数为2的幂次。

Practice: Use a K‑map to minimise F(A,B,C) = Σ(1,2,3,6,7). (Answer: F = A·B + A’·C + B·C? Actually simplify: groups: 1,3 -> A’·C; 2,3,6,7 -> B; so F = B + A’·C.)

练习:使用卡诺图化简 F(A,B,C) = Σ(1,2,3,6,7)。(答案:F = B + A’·C)


6. Memory and Storage Calculations | 存储容量计算

Memory sizes are often specified with prefixes: kilo (10³), mega (10⁶), giga (10⁹), but in computing, binary prefixes (kibi 2¹⁰ = 1024, mebi 2²⁰, gibi 2³⁰) are used for RAM. Always check the context of the exam question. To calculate the number of addressable locations, raise 2 to the power of the address bus width. A 16‑bit address bus can address 2¹⁶ = 65536 locations.

存储容量常使用前缀:千(10³)、兆(10⁶)、吉(10⁹),但在计算领域,RAM 使用二进制前缀(kibi 2¹⁰=1024,mebi 2²⁰,gibi 2³⁰)。务必根据考题背景判断。可寻址单元数通过将2的地址总线宽度次方来计算。16位地址总线可寻址 2¹⁶ = 65536 个单元。

If each memory location stores 1 byte, the total capacity = number of locations × 1 byte. For a 24‑bit address bus with a 32‑bit data bus, capacity = 2²⁴ × 4 bytes = 16 Mi × 4 = 64 MiB (mebibytes).

若每个存储单元存储 1 字节,总容量 = 单元数 × 1 字节。对于 24 位地址总线和 32 位数据总线,容量 = 2²⁴ × 4 字节 = 16 Mi × 4 = 64 MiB。

Example: A microprocessor has a 20‑bit address bus and an 8‑bit data bus. How many kilobytes can it address? 2²⁰ = 1,048,576 locations, each 1 byte → 1,048,576 bytes = 1024 KiB = 1 MiB. In decimal kilobytes: 1048.576 KB.

示例:微处理器具有 20 位地址总线和 8 位数据总线。它能寻址多少千字节?2²⁰ = 1,048,576 个单元,每个 1 字节 → 1,048,576 字节 = 1024 KiB = 1 MiB。若按十进制千字节计,为 1048.576 KB。

Practice: A 32‑bit address bus with a 16‑bit data bus is used. Calculate the total addressable memory in gibibytes. (Answer: 2³² × 2 bytes = 8 GiB, since 2³² = 4 Gi, times 2 = 8 GiB.)

练习:使用 32 位地址总线和 16 位数据总线。计算总可寻址内存(以 GiB 为单位)。(答案:2³² × 2 字节 = 8 GiB,因 2³² = 4 Gi,乘以 2 得 8 GiB。)


7. Image and Sound File Size | 图像与声音文件大小

An uncompressed bitmap image file size (in bits) = image width in pixels × image height in pixels × colour depth (bits per pixel). For an 800×600 image with 24‑bit colour, size = 800 × 600 × 24 = 11,520,000 bits = 1,440,000 bytes ≈ 1.37 MiB.

未压缩的位图图像文件大小(以位计)= 图像宽度(像素)× 图像高度(像素)× 色彩深度(每像素位数)。对于 800×600、24 位色彩的图像,大小 = 800 × 600 × 24 = 11,520,000 位 = 1,440,000 字节 ≈ 1.37 MiB。

For sound, file size = sample rate (Hz) × sample resolution (bits) × duration (seconds) × number of channels. A 1‑minute stereo recording at 44.1 kHz with 16‑bit resolution: 44100 × 16 × 60 × 2 = 84,672,000 bits = 10,584,000 bytes ≈ 10.09 MB.

对于声音,文件大小 = 采样率(Hz)× 采样分辨率(位)× 时长(秒)× 声道数。一段 1 分钟的立体声录音,采样率 44.1 kHz,16 位分辨率:44100 × 16 × 60 × 2 = 84,672,000 位 = 10,584,000 字节 ≈ 10.09 MB。

When compression is applied, multiply the uncompressed size by the compression ratio (e.g., 10:1 means new size = original size / 10). Always convert units carefully: 1 byte = 8 bits, 1 KB = 1024 bytes (binary) or 1000 bytes (decimal) depending on context.

应用压缩时,将未压缩大小乘以压缩比(例如 10:1 表示新大小 = 原大小 / 10)。务必小心换算单位:1 字节 = 8 位,1 KB = 1024 字节(二进制)或 1000 字节(十进制),视上下文而定。

Practice: Calculate the uncompressed file size in megabytes for a 5‑minute mono audio track sampled at 48 kHz with 24‑bit resolution. (Answer: 48000 × 24 × 300 × 1 = 345,600,000 bits = 43,200,000 bytes ≈ 41.2 MB if 1 MB = 1,048,576 bytes; or 43.2 MB decimal.)

练习:计算一段 5 分钟单声道音轨的未压缩文件大小(以 MB 计),采样率 48 kHz,24 位分辨率。(答案:48000 × 24 × 300 × 1 = 345,600,000 位 = 43,200,000 字节,若 1 MB = 1,048,576 字节,约为 41.2 MB;或 43.2 MB 十进制。)


8. Data Transfer Time | 数据传输时间

Transfer time (seconds) = amount of data (bits) / bandwidth (bits per second, bps). Ensure consistent units. For example, downloading a 50 MiB file over a 100 Mbps connection: convert file size to megabits: 50 MiB × 8 = 400 Mib (mebibits?) Actually 50 MiB = 50 × 1024 × 1024 × 8 bits = 419,430,400 bits. Bandwidth 100 Mbps = 100,000,000 bps. Time = 419,430,400 / 100,000,000 ≈ 4.19 seconds. In exam context, often 1 MB = 10⁶ bytes.

传输时间(秒)= 数据量(位)/ 带宽(每秒位数,bps)。确保单位一致。例如,用 100 Mbps 连接下载一个 50 MiB 文件:将文件大小转换为兆位:50 MiB × 8 = 400 Mib?实际上 50 MiB = 50 × 1024 × 1024 × 8 位 = 419,430,400 位。带宽 100 Mbps = 100,000,000 bps。时间 = 419,430,400 / 100,000,000 ≈ 4.19 秒。在考试中,通常 1 MB = 10⁶ 字节。

If using decimal megabytes (MB), 50 MB = 50,000,000 bytes = 400,000,000 bits. Time = 400,000,000 / 100,000,000 = 4 seconds exactly. Always read the question to know whether binary or decimal prefixes are expected.

若使用十进制兆字节(MB),50 MB = 50,000,000 字节 = 400,000,000 位。时间 = 400,000,000 / 100,000,000 = 4 秒整。务必阅读题目以明确期望使用二进制还是十进制前缀。

Additionally, consider protocol overheads: for TCP/IP, about 2–5% overhead may reduce effective throughput. A question might ask for the time including a 10% overhead: multiply time by 1.10.

此外,需考虑协议开销:对于 TCP/IP,大约 2–5% 的开销会降低有效吞吐量。题目可能要求计算包含 10% 开销的时间:将时间乘以 1.10。

Practice: How long to transmit a 2 GB file over a 54 Mbps Wi‑Fi connection? Assume 1 GB = 10⁹ bytes and no overhead. (Answer: 2 GB = 16,000,000,000 bits; 54 Mbps = 54,000,000 bps; time ≈ 296.3 seconds ≈ 4.94 minutes.)

练习:通过 54 Mbps Wi‑Fi 连接传输 2 GB 文件需要多长时间?假设 1 GB = 10⁹ 字节,无开销。(答案:2 GB = 16,000,000,000 位;54 Mbps = 54,000,000 bps;时间 ≈ 296.3 秒 ≈ 4.94 分钟。)


9. Floating Point Binary Representation | 浮点二进制表示

Floating point stores real numbers as sign, exponent, and mantissa. Normalise the mantissa so that its first bit is 1 (for positive) or 0 (for negative) to maximise precision. Convert 5.75 to 8‑bit floating point with 1 sign bit, 3 exponent bits (excess‑3), 4 mantissa bits. 5.75 = 101.11₂ → normalise to 1.0111 × 2². Sign = 0, exponent = 2 + 3 = 5 = 101₂, mantissa = 0111 (drop the leading 1). Result: 0 101 0111.

浮点数将实数存储为符号位、指数和尾数。对尾数进行规格化,使其第一位为1(正数)或0(负数),以最大化精度。将 5.75 转换为 8 位浮点数(1 位符号,3 位指数(偏移 3),4 位尾数)。5.75 = 101.11₂ → 规格化 1.0111 × 2²。符号 = 0,指数 = 2+3 = 5 = 101₂,尾数 = 0111(去掉前导 1)。结果:0 101 0111。

Denormalised numbers (exponent all zeros) represent values very close to zero. When converting back, use the formula: value = (−1)^sign × (1.mantissa) × 2^(exponent−bias). For the example above: (−1)⁰ × 1.0111 × 2^(5−3) = 1.0111 × 2² = 101.11₂ = 5.75.

非规格化数(指数全零)表示非常接近零的值。反向转换时,使用公式:值 = (−1)^sign × (1.尾数) × 2^(指数−偏移)。对于上例:(−1)⁰ × 1.0111 × 2^(5−3) = 1.0111 × 2² = 101.11₂ = 5.75。

Precision is limited; rounding errors occur. Understand how the number of mantissa bits affects the smallest difference that can be represented.

精度有限;会产生舍入误差。理解尾数位数如何影响可表示的最小差值。

Practice: Represent −2.25 using 1 sign bit, 4 exponent bits (excess‑7), 5 mantissa bits. (Answer: 1 0100 00100? Let’s compute: 2.25 = 10.01₂ → 1.001 × 2¹. Sign=1, exponent=1+7=8=1000₂, mantissa=00100 → 1 1000 00100.)

练习:用 1 位符号位、4 位指数位(偏移 7)、5 位尾数表示 −2.25。(答案:1 1000 00100)


10. Subnet Mask and Network Addressing | 子网掩码与网络寻址

Subnetting divides a large IP network into smaller sub‑networks using a subnet mask. The mask is a 32‑bit number where network bits are 1, host bits are 0. With a /24 mask (255.255.255.0), the first 24 bits define the network, leaving 8 bits for hosts. Number of usable host addresses = 2^(host bits) − 2 (excluding network and broadcast addresses).

子网划分使用子网掩码将大型 IP 网络划分为更小的子网络。掩码是一个 32 位数,网络位为 1,主机位为 0。对于 /24 掩码(255.255.255.0),前 24 位定义网络,留下 8 位给主机。可用主机地址数 = 2^(主机位数) − 2(排除网络地址和广播地址)。

Given an IP address 192.168.1.0/26, the subnet mask is 255.255.255.192. The 26 network bits leave 6 host bits, so 2⁶ − 2 = 62 usable addresses per subnet. The subnet increment is 64 (2^(32−26)=64), giving subnets 192.168.1.0, 192.168.1.64, 192.168.1.128, 192.168.1.192.

给定 IP 地址 192.168.1.0/26,子网掩码为 255.255.255.192。26 位网络位留下 6 位主机位,因此每个子网有 2⁶ − 2 = 62 个可用地址。子网增量为 64(2^(32−26)=64),得到子网 192.168.1.0、192.168.1.64、192.168.1.128、192.168.1.192。

To find the network address for a host, perform a bitwise AND between the host IP and the subnet mask. For 192.168.1.100/26, AND with 255.255.255.192 yields 192.168.1.64, so it belongs to that subnet.

要查找某主机的网络地址,对主机 IP 和子网掩码执行按位 AND 运算。对于 192.168.1.100/26,与 255.255.255.192 进行 AND 运算得到 192.168.1.64,因此它属于该子网。

Practice: How many usable host addresses in a /20 network? What is the subnet mask in dotted decimal? (Answer: 2¹² − 2 = 4094; mask 255.255.240.0.)

练习:/20 网络中有多少个可用主机地址?子网掩码的点分十进制是什么?(答案:2¹² − 2 = 4094;掩码 255.255.240.0。)


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