IB WJEC Computer Science: Formula Handbook | IB WJEC 计算机:公式汇总手册

📚 IB WJEC Computer Science: Formula Handbook | IB WJEC 计算机:公式汇总手册

In IB and WJEC Computer Science, mastering key formulas is essential for solving problems in data representation, Boolean logic, networking, and algorithm analysis. This handbook compiles the most important equations and concepts you need for your exams, with clear explanations in both English and Chinese.

在IB和WJEC计算机科学课程中,掌握关键公式对于解决数据表示、布尔逻辑、网络和算法分析问题至关重要。本手册汇编了考试所需的最重要的公式和概念,并配有清晰的中英文解释。


1. Number Systems & Conversions | 数制与转换

A number in any base r can be expanded as the sum of each digit multiplied by the base raised to the power of its position. The rightmost integer position is position 0.

任何基数 r 的数都可以展开为每个数位乘以基数位权再求和的形式。最右侧的整数位位置为 0。

Decimal Value = dₙ₋₁ × rⁿ⁻¹ + dₙ₋₂ × rⁿ⁻² + … + d₀ × r⁰ + d₋₁ × r⁻¹ + …

For example, converting binary 1011₂ to decimal: 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11₁₀. Hexadecimal digits A–F represent values 10–15, so A₁₆ = 10, 2F₁₆ = 2×16¹ + 15×16⁰ = 47.

例如,将二进制 1011₂ 转换为十进制:1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 8 + 0 + 2 + 1 = 11₁₀。十六进制数字 A–F 代表 10–15,因此 A₁₆ = 10,2F₁₆ = 2×16¹ + 15×16⁰ = 47。

To convert decimal to another base, repeatedly divide the integer part by the new base and collect remainders from bottom to top. For fractional parts, multiply by the new base and collect integer parts.

要将十进制转换为其他进制,将整数部分不断除以新基数,从下往上收集余数。对于小数部分,乘以新基数并收集整数部分。


2. Binary Arithmetic & Signed Integers | 二进制运算与有符号整数

Binary addition follows the rules 0+0=0, 1+0=1, 1+1=10 (0 with carry 1). Overflow occurs when the result exceeds the representable range for a fixed number of bits, indicated by a carry into the sign bit.

二进制加法规则:0+0=0,1+0=1,1+1=10(本位为 0,进位 1)。当结果超出固定位数的表示范围时发生溢出,通常表现为进位进入符号位。

Two’s complement of A: −A = (¬A) + 1

To store a negative integer using two’s complement, invert all bits (bitwise NOT) and add 1. The range for an n-bit two’s complement integer is −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1. For example, with 8 bits the range is −128 to 127.

使用二进制补码存储负整数:先按位取反,再加 1。对于 n 位补码整数,范围是 −2ⁿ⁻¹ 到 2ⁿ⁻¹ − 1。例如,8 位补码的范围是 −128 到 127。


3. Boolean Algebra & Logic Simplification | 布尔代数与逻辑简化

Boolean algebra uses variables with values true (1) and false (0). Basic operators are AND ( ∧ ), OR ( ∨ ), and NOT ( ¬ ). Key laws enable simplification of logic circuits.

布尔代数使用取值为真(1)和假(0)的变量。基本运算符包括与(∧)、或(∨)和非(¬)。重要定律可简化逻辑电路。

De Morgan’s Laws:
¬(A ∧ B) ≡ ¬A ∨ ¬B
¬(A ∨ B) ≡ ¬A ∧ ¬B

Other useful identities include the distributive law A ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C), and absorption A ∨ (A ∧ B) = A. These are used to minimise gate counts in digital design.

其他有用的恒等式包括分配律 A ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C),以及吸收律 A ∨ (A ∧ B) = A。这些用于减少数字电路中的门数量。


4. Data Storage Units & Text Size | 数据存储单位与文本大小

Digital data is measured in bits and bytes. In computer science, prefixes typically use powers of 2: 1 KB = 2¹⁰ bytes = 1024 bytes, 1 MB = 2²⁰ bytes, 1 GB = 2³⁰ bytes. (Storage manufacturers often use powers of 10, but exam contexts usually stick to binary prefixes.)

数字数据以位和字节为单位。在计算机科学中,前缀通常采用 2 的幂:1 KB = 2¹⁰ 字节 = 1024 字节,1 MB = 2²⁰ 字节,1 GB = 2³⁰ 字节。(存储设备厂商常使用 10 的幂,但考试通常使用二进制前缀。)

Text file size (bits) = Number of characters × Bits per character

For plain ASCII (7‑bit or 8‑bit extended), a 1000‑character text file uses 8000 bits = 1000 bytes. Unicode UTF‑8 uses 1‑4 bytes per character; basic Latin characters still use 8 bits.

对于纯 ASCII(7 位或 8 位扩展),一个 1000 字符的文本文件占用 8000 位 = 1000 字节。Unicode UTF‑8 每个字符使用 1 至 4 字节;基本拉丁字符仍使用 8 位。


5. Image & Sound File Size Calculation | 图像与声音文件大小计算

The uncompressed size of a bitmap image depends on its resolution and colour depth. Colour depth is the number of bits used to represent the colour of a single pixel.

位图图像未压缩时的大小取决于分辨率和色彩深度。色彩深度是表示单个像素颜色所用的位数。

Image file size (bits) = Width × Height × Colour depth

For a 1920×1080 image with 24‑bit colour (3 bytes per pixel), the raw size is 1920 × 1080 × 24 = 49,766,400 bits ≈ 6.22 MB. Metadata (e.g., header) may add a small overhead.

对于具有 24 位色彩(每像素 3 字节)的 1920×1080 图像,原始大小为 1920 × 1080 × 24 = 49,766,400 位 ≈ 6.22 MB。元数据(如文件头)可能会增加少量额外开销。

Sound file size (bits) = Sample rate × Bit depth × Channels × Duration (seconds)

For CD‑quality audio (44,100 Hz, 16‑bit, stereo), one minute of sound requires 44,100 × 16 × 2 × 60 = 84,672,000 bits ≈ 10.09 MB.

对于 CD 品质音频(44,100 Hz、16 位、立体声),一分钟的声音需要 44,100 × 16 × 2 × 60 = 84,672,000 位 ≈ 10.09 MB。


6. Compression Ratios | 压缩比

Compression reduces file size by removing redundancy. The compression ratio quantifies effectiveness, while the space saving percentage shows the reduction relative to the original.

压缩通过去除冗余来减小文件大小。压缩比用于衡量有效性,而空间节省百分比则显示相对于原始文件的缩减程度。

Compression Ratio = Uncompressed Size ÷ Compressed Size
Space Saving (%) = (1 − Compressed Size ÷ Uncompressed Size) × 100%

If a 5 MB file compresses to 2 MB, the compression ratio is 5 ÷ 2 = 2.5 : 1, and the space saving is (1 − 2/5) × 100% = 60%.

如果一个 5 MB 的文件被压缩为 2 MB,压缩比是 5 ÷ 2 = 2.5 : 1,空间节省为 (1 − 2/5) × 100% = 60%。


7. Error Detection: Parity & Check Digits | 差错检测:奇偶校验与校验位

Parity bits are simple error‑detection codes. A single parity bit is appended so that the total number of 1s in the data unit (including the parity bit) is even (even parity) or odd (odd parity).

奇偶校验位是一种简单的差错检测码。添加一个校验位,使得数据单元(包括校验位)中 1 的总数为偶数(偶校验)或奇数(奇校验)。

Even parity bit = D₁ ⊕ D₂ ⊕ … ⊕ Dₙ
(XOR of all data bits)

If the data bits are 1010, the XOR gives 1⊕0⊕1⊕0 = 0, so the even parity bit is 0, making the transmitted string 10100. The receiver recalculates the XOR; a mismatch indicates an odd number of bit errors.

如果数据位是 1010,XOR 运算为 1⊕0⊕1⊕0 = 0,因此偶校验位为 0,发送的字符串为 10100。接收方重新计算 XOR;若不匹配则表明出现了奇数个位错误。


8. Network Transmission Calculations | 网络传输计算

Transmission delay is the time needed to push all the bits of a file onto the link, determined by the bandwidth. Propagation delay is the time for a single bit to travel across the physical medium.

传输延迟是将文件的所有比特推送到链路上所需的时间,由带宽决定。传播延迟是单个比特穿越物理介质所需的时间。

Transmission time = File size (bits) ÷ Bandwidth (bps)
Propagation delay = Distance ÷ Propagation speed

For example, sending a 1 MB (8,388,608 bits) file over a 10 Mbps link takes 8,388,608 ÷ 10,000,000 ≈ 0.839 seconds of transmission time. If the cable is 100 km and signals travel at 2×10⁸ m/s, propagation delay is 100,000 ÷ 200,000,000 = 0.0005 seconds.

例如,通过 10 Mbps 的链路发送一个 1 MB(8,388,608 位)的文件,传输时间为 8,388,608 ÷ 10,000,000 ≈ 0.839 秒。若电缆长 100 km,信号以 2×10⁸ m/s 的速度传播,则传播延迟为 100,000 ÷ 200,000,000 = 0.0005 秒。

Total latency often also includes queuing and processing delays, but in exam problems the sum of transmission and propagation delay is the typical focus.

总延迟通常还包括排队和处理延迟,但在考试题目中通常重点关注传输延迟和传播延迟之和。


9. Algorithm Complexity & Big O Notation | 算法复杂度和大 O 记号

Big O notation describes how the runtime or space requirement of an algorithm grows with input size n. Common complexities often tested are listed below.

大 O 记号描述算法的运行时间或空间需求如何随输入规模 n 增长。以下是常考的常见复杂度。

Linear search: O(n)
Binary search: O(log₂ n)
Bubble sort (comparisons): O(n²) — exact: n(n−1)/2
Merge sort: O(n log₂ n)

For recursive algorithms, a recurrence relation models the time. For example, binary search follows T(n) = T(n/2) + O(1), which solves to O(log n). Merge sort’s recurrence T(n) = 2T(n/2) + O(n) gives O(n log n).

对于递归算法,可用递推关系来建模时间。例如,二分搜索满足 T(n) = T(n/2) + O(1),解得 O(log n)。归并排序的递推式 T(n) = 2T(n/2) + O(n) 得到 O(n log n)。


10. Floating Point Representation | 浮点数表示

Real numbers are stored in floating‑point format as sign, mantissa (fractional part) and exponent. A bias is subtracted from the stored exponent to allow negative exponents. The general formula for normalised binary floating point is shown below.

实数以浮点格式存储为符号尾数(小数部分)和指数。从存储的指数中减去一个偏移量以表示负指数。归一化二进制浮点数的一般公式如下。

Value = (−1)ˢ × (1 + m) × 2ᵉ⁻ᵇ
where b = 2ᵏ⁻¹ − 1 (bias, k = exponent bits)

In the mantissa, the leading ‘1’ is implied in normalised form. If the mantissa has n bits, it represents a fraction

Published by TutorHao | IB 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