📚 IB Edexcel Computer Science: Formula Cheat Sheet | IB Edexcel 计算机:公式汇总手册
Welcome to your go-to formula compilation for IB and Edexcel Computer Science. This handbook gathers all the essential quantitative relationships you need to handle exam questions on data representation, file sizes, network performance, Boolean algebra, algorithm analysis, and more. Bookmark this page and use it as a quick revision reference.
欢迎查阅专为 IB 与 Edexcel 计算机科学整理的公式手册。本汇总涵盖数据处理、文件大小、网络性能、布尔代数、算法分析等常考定量关系,是考前快速回顾的最佳伴侣。建议收藏并反复翻阅。
1. Data Storage & File Size Basics | 数据存储与文件大小基础
The fundamental unit of digital data is the bit (b). Eight bits form one byte (B). For larger volumes, we use binary prefixes where each step multiplies by 1024. The size of any digital file is simply the number of bits or bytes required to store its content.
数字数据的基本单位是比特 (bit),8 比特构成 1 字节 (Byte)。更大的容量使用二进制前缀,每一步乘以 1024。任何数字文件的大小即存储其内容所需的总比特数或总字节数。
1 byte = 8 bits
1 KB = 1024 B, 1 MB = 1024 KB, 1 GB = 1024 MB, 1 TB = 1024 GB
| Unit | Equivalent in bytes | 单位 | 等值字节数 |
|---|---|---|---|
| 1 KB | 2¹⁰ B = 1024 B | 1 KB | 1024 B |
| 1 MB | 2²⁰ B = 1,048,576 B | 1 MB | 1,048,576 B |
| 1 GB | 2³⁰ B = 1,073,741,824 B | 1 GB | 约 10.74 亿字节 |
| 1 TB | 2⁴⁰ B = 1,099,511,627,776 B | 1 TB | 约 1.1 万亿字节 |
2. Image File Size | 图像文件大小
A bitmap image is composed of a grid of pixels. Each pixel has a colour defined by a certain number of bits — the colour depth. The total image file size (in bits) is the product of width, height, and colour depth.
位图图像由像素网格组成。每个像素的颜色使用特定位数表示,即位深度。图像文件大小(以比特计)等于宽度、高度和位深度的乘积。
S = W × H × D
height in pixels, D = colour depth (bits per pixel). To obtain size in bytes, divide by 8.
其中 W = 图像宽度(像素),H = 高度(像素),D = 位深度(每像素比特数)。要得到以字节为单位的大小,再除以 8。
- Example: A 1920×1080 image with 24‑bit colour: S = 1920 × 1080 × 24 = 49,766,400 bits ≈ 5.93 MB.
- 示例:1920×1080 分辨率、24 位色深的图像:S = 1920 × 1080 × 24 = 49,766,400 比特 ≈ 5.93 MB。
3. Audio File Size | 音频文件大小
Uncompressed audio size depends on the sample rate, bit depth, duration, and number of channels. The formula computes the total bits captured during recording.
未压缩音频的大小取决于采样率、位深度、时长和声道数。该公式计算录制过程中捕获的总比特数。
S = fₛ × b × t × c
r mono, 2 for stereo). Result is in bits; divide by 8 for bytes, then by 1024 for KB, etc.
fₛ = 采样率(Hz),b = 位深度(每样本比特数),t = 时长(秒),c = 声道数(单声道为 1,立体声为 2)。结果单位为比特;除以 8 得字节,再依次除以 1024 可得 KB 等。
- Example: CD‑quality stereo (44.1 kHz, 16‑bit) for 3 minutes: S = 44,100 × 16 × 180 × 2 = 254,016,000 bits ≈ 30.3 MB.
- 示例:CD 质量立体声(44.1 kHz、16 位)3 分钟:S = 44,100 × 16 × 180 × 2 = 254,016,000 比特 ≈ 30.3 MB。
4. Video File Size | 视频文件大小
Video combines a sequence of images (frames) with an audio track. The raw size is the sum of the image stream and the audio stream. Compression is heavily applied in practice, but this raw calculation gives the theoretical maximum.
视频由一系列图像(帧)与音频轨道组合而成。其原始大小等于图像流与音频流之和。实际应用会大幅压缩,但此原始计算给出理论上限。
Svideo = (W × H × D × r × t) + (fₛ × b × t × c)
n in seconds. The first part represents the image frames, the second part the audio. The result is in bits.
其中 r = 帧率(fps),t = 时长(秒)。前半部分代表图像帧,后半部分代表音频。结果以比特为单位。
5. Network Transmission Time | 网络传输时间
The time needed to transfer a file over a network depends on the file size and the available bandwidth (transfer speed). Always ensure units match — bits per second (bps) for speed and bits for file size.
通过网络传输文件所需的时间取决于文件大小和可用带宽(传输速率)。务必确保单位一致 — 速率用比特每秒(bps),文件大小用比特。
T = S / R
= transfer rate (bps). For practical speeds given in bytes per second, convert S to bytes.
T = 时间(秒),S = 文件大小(比特),R = 传输速率(bps)。若实际速率以字节每秒给出,需将 S 转换为字节后计算。
- Example: tion: S = 500 × 1024² × 8 = 4,194,304,000 bits. T = 4,194,304,000 / 100,000,000 ≈ 41.94 s.
- 示例:通过 100 Mbps 链路发送 500 MB:S = 500 × 1024² × 8 = 4,194,304,000 比特。T = 4,194,304,000 / 100,000,000 ≈ 41.94 秒。
6. Compression Ratio | 压缩比
Compression reduces file size. The compression ratio measures effectiveness. A higher ratio means greater size reduction. Space saving percentage tells you how much storage is freed.
压缩可减小文件体积。压缩比用于衡量压缩效果。比值越高,尺寸减小越多。空间节省百分比则表示节省了多少存储空间。
Compression Ratio = Original Size / Compressed Size
Space Saving (%) = (1 − (Compressed Size / Original Size)) × 100%
- Example: A 20 MB file compressed to 5 MB → ratio = 4:1, space saving = 75%.
- 示例:20 MB 文件压缩至 5 MB → 压缩比 4:1,节省 75% 空间。
7. Number Systems & Conversions | 数制与转换
Computers use binary (base‑2), and we often work with decimal (base‑10) and hexadecimal (base‑16). Conversions follow place‑value weighting. No single numeric formula exists, but the process is systematic.
计算机使用二进制(基数为 2),我们常处理十进制(基数为 10)和十六进制(基数为 16)。转换遵循位权展开,虽无单一公式但步骤系统化。
- Binary to Decimal: Sum of (bit × 2position) from rightmost 2⁰. E.g., 1011₂ = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 11₁₀.
- 二进制转十进制:每位数字乘以 2 的位权次幂求和,最右为 2⁰。例:1011₂ = 1×2³ + 0×2² + 1×2¹ + 1×2⁰ = 11₁₀。
- Decimal to Binary: Repeated division by 2, read remainders in reverse order.
- 十进制转二进制:重复除以 2,取余数逆序排列。
- Hex ↔ Binary: Group bits in fours from the right, then convert each group to one hex digit (0‑9, A‑F).
- 十六进制 ↔ 二进制:从右起每 4 位一组,每组转换为一个十六进制数字(0‑9, A‑F)。
- Hex ↔ Decimal: First convert hex to binary, then to decimal; or use place‑value with base‑16: dₙ×16ⁿ + …
- 十六进制 ↔ 十进制:可先转为二进制再转十进制;或直接按基 16 位权展开:dₙ×16ⁿ + …
8. Boolean Algebra Laws | 布尔代数定律
Boolean algebra deals with binary variables and logic operations (AND, OR, NOT). The laws simplify logic circuits and expressions. Key identities are listed below (using ∧ for AND, ∨ for OR, ¬ for NOT).
布尔代数处理二元变量及逻辑运算(与、或、非)。以下定律用于简化逻辑电路和表达式(使用 ∧ 表示与,∨ 表示或,¬ 表示非)。
| Law (English) | Expression | 定律(中文) |
|---|---|---|
| Identity | A ∨ 0 = A, A ∧ 1 = A | 恒等律 |
| Null (Domination) | A ∨ 1 = 1, A ∧ 0 = 0 | 零一律(支配律) |
| Idempotent | A ∨ A = A, A ∧ A = A | 幂等律 |
| Complement | A ∨ ¬A = 1, A ∧ ¬A = 0 | 互补律 |
| Double Negation | ¬(¬A) = A | 双重否定律 |
| Commutative | A ∨ B = B ∨ A, A ∧ B = B ∧ A | 交换律 |
| Associative | (A ∨ B) ∨ C = A ∨ (B ∨ C), (A ∧ B) ∧ C = A ∧ (B ∧ C) | 结合律 |
| Distributive | A ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C), A ∨ (B ∧ C) = (A ∨ B) ∧ (A ∨ C) | 分配律 |
| Absorption | A ∨ (A ∧ B) = A, A ∧ (A ∨ B) = A | 吸收律 |
| De Morgan's | ¬(A ∧ B) = ¬A ∨ ¬B, ¬(A ∨ B) = ¬A ∧ ¬B | 德摩根定律 |
9. Logic Simplification (Karnaugh Maps) | 逻辑化简(卡诺图)
Karnaugh maps (K‑maps) are a visual tool to minimise Boolean functions. The grouping rule is: group adjacent 1s in powers of two (1,2,4,8…) to form the largest possible rectangles. Each group corresponds to a product term where variables that change are eliminated.
卡诺图(K‑map)是化简布尔函数的可视化工具。其分组规则为:将相邻的 1 按 2 的幂次(1,2,4,8…)圈成尽可能大的矩形。每组对应一个乘积项,其中发生变化的变量被消去。
- For a 2‑variable map, a group of two eliminates 1 variable; a group of four eliminates both.
- 对于二变量卡诺图,包含 2 个 1 的组消去 1 个变量;包含 4 个 1 的组消去全部变量。
- In a 3‑variable map, group sizes of 2,4,8 remove 1,2,3 variables respectively.
- 三变量图中,分组大小为 2、4、8 分别消去 1、2、3 个变量。
- Don't‑care conditions (marked 'X') can be treated as 0 or 1 to enlarge groups.
- 无关项(标记为 'X')可当作 0 或 1 使用,以扩大分组。
10. Algorithm Complexity (Big O Notation) | 算法复杂度(大 O 表示法)
Big O notation expresses the upper bound of an algorithm's running time or space usage as a function of input size n. It describes how performance scales.
大 O 表示法表达算法运行时间或空间占用随输入规模 n 增长的上界,描述性能的伸缩趋势。
| Complexity | Name | Example | 复杂度 | 名称 | 示例 |
|---|---|---|---|---|---|
| O(1) | Constant | Array access by index | 常数 | 常数时间 | 按索引访问数组 |
| O(log n) | Logarithmic | Binary search | 对数 | 对数时间 | 二分查找 |
| O(n) | Linear | Linear search | 线性 | 线性时间 | 顺序查找 |
| O(n log n) | Linearithmic | Merge sort, heap sort | 线性对数 | 线性对数时间 | 归并排序、堆排序 |
| O(n²) | Quadratic | Bubble sort, selection sort | 平方 | 平方时间 | 冒泡排序、选择排序 |
| O(2ⁿ) | Exponential | Recursive Fibonacci | 指数 | 指数时间 | 递归计算斐波那契 |
11. Data Transfer Rate & Bandwidth | 数据传输率与带宽
Bandwidth refers to the maximum data transfer capacity of a network connection, measured in bits per second (bps). The effective throughput is often lower due to protocol overhead and network conditions. The relationship between data volume, time, and rate mirrors the transmission time formula.
带宽指网络连接的最大数据传输能力,单位为比特每秒 (bps)。受协议开销和网络状况影响,实际吞吐量常低于理论值。数据量、时间与速率的关系与传输时间公式一致。
Bandwidth = Data Transferred / Time (in seconds)
lways use consistent units. A common pitfall is mixing bytes (B) with bits (b): 1 B = 8 b.
此外,根据文件大小和带宽计算下载时间时,务必保持单位一致。常见错误是混淆字节 (B) 与比特 (b):1 B = 8 b。
12. Error Detection: Parity & Checksum | 错误检测:奇偶校验与校验和
Simple error‑detection methods use mathematical formulas to generate a check value. A parity bit ensures the total number of 1s in a byte is even (even parity) or odd (odd parity). A checksum sums data blocks and transmits the sum; the receiver compares the recalculated sum with the received checksum.
简单的错误检测方法借助数学运算生成校验值。奇偶校验位确保一个字节中 1 的个数为偶数(偶校验)或奇数(奇校验)。校验和则对数据块求和并传输该和值;接收方重新计算和并与收到的校验和比对。
- Even parity bit: P = (b₇ ⊕ b₆ ⊕ … ⊕ b₀) (XOR of all data bits; set P so that total number of 1s is even).
- 偶校验位:P = (b₇ ⊕ b₆ ⊕ … ⊕ b₀)(对所有数据位进行异或;选择 P 使总 1 数为偶数)。
- Checksum: Sum of data words (mod 256 for 8‑bit checksum) appended to message.
- 校验和:将数据字(8 位校验和则模 256)相加,结果附加到报文后。
- iver checks: (sum of received data + checksum) mod 2ⁿ = 0 (for one’s complement checksum).
- 接收端验证:(收到的数据和 + 校验和)模
Published by TutorHao | IB Computer Science Revision Series | aleveler.com
广告 / SponsoredIBDP国际文凭计算机科学学生用书 高级及标准水平 Computer Science for the IB Diplo…计算机 备考教辅 · 正版现货 · 与本文内容相关查看详情 / View on Taobao参考价 ¥524.0更多咨询请联系16621398022(同微信)
备考资讯每日更新,关注不错过考纲变化 · 科目分析 · 学习方法
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图公众号:tutorhao