A-Level Computer Science Formula Summary Handbook | A-Level 计算机:公式汇总手册

📚 A-Level Computer Science Formula Summary Handbook | A-Level 计算机:公式汇总手册

This handbook collates essential formulas, laws, and quantitative relationships covered in the A-Level Computer Science syllabus. The material spans data representation, processor performance, Boolean algebra, algorithm complexity, networks, databases, and security, providing a quick-reference revision resource.

本手册汇集了 A-Level 计算机科学课程中的核心公式、定律与数量关系,涵盖数据表示、处理器性能、布尔代数、算法复杂度、网络、数据库和安全等领域,为复习提供快速查阅的参考资源。


1. Data Storage & File Size Calculations | 数据存储与文件大小计算

The size of a digital file is determined by the amount of raw data it contains. Bit, byte and their multiples are the fundamental units. Conversions follow powers of 2 in most computing contexts.

数字文件的大小由其包含的原始数据量决定。位、字节及其倍数是最基本单位,在计算机领域换算通常基于 2 的幂。

1 byte = 8 bits
1 KB = 2¹⁰ bytes = 1024 bytes
1 MB = 2²⁰ bytes = 1,048,576 bytes
1 GB = 2³⁰ bytes
1 TB = 2⁴⁰ bytes

For an uncompressed image: File size (bits) = number of pixels × colour depth (bits per pixel). For a rectangle image, pixels = width × height.

对于未压缩图像:文件大小(位)= 像素总数 × 色彩深度(每像素位数)。矩形图像的像素数 = 宽度 × 高度。

Image size (bits) = width × height × bit depth

Example: a 1024 × 768 image with 24-bit colour requires 1024 × 768 × 24 = 18,874,368 bits (≈ 2.25 MB).

示例:一幅 1024×768、24 位色彩的图像需要 1024 × 768 × 24 = 18,874,368 位(约 2.25 MB)。


2. Sound & Image Representation Formulas | 声音与图像表示公式

Digital audio size depends on sampling rate, bit depth, number of channels and duration. The formula gives the total number of bits needed to store a raw sound clip.

数字音频的大小取决于采样率、位深度、声道数和时长。以下公式给出了存储原始音频片段所需的总位数。

Sound size (bits) = sample rate (Hz) × bit depth × duration (seconds) × number of channels

For stereo CD-quality audio (44,100 Hz, 16-bit, 2 channels) lasting 1 second, size = 44,100 × 16 × 1 × 2 = 1,411,200 bits (176,400 bytes).

对于 1 秒立体声 CD 音质(44,100 Hz、16 位、2 声道),大小 = 44,100 × 16 × 1 × 2 = 1,411,200 位(176,400 字节)。

When considering quantisation levels, the number of discrete levels equals 2^bit depth. For images, colour depth directly determines the number of available colours = 2^(bit depth).

考虑量化级别时,离散电平数等于 2^(位深度)。对于图像,色彩深度直接决定可用颜色数 = 2^(色彩深度)。


3. Processor Performance Formulas | 处理器性能公式

The execution time of a program on a CPU is fundamentally linked to the instruction count, the average cycles per instruction (CPI), and the clock frequency. These form the classic CPU performance equation.

程序在 CPU 上的执行时间从根本上与指令数、平均每指令周期数(CPI)和时钟频率有关,构成了经典的 CPU 性能方程。

CPU time (seconds) = (Instruction Count × CPI) / Clock rate

Clock rate can be expressed in Hz; if CPI = 1.5, instruction count = 12 million, and clock rate = 3 GHz, then CPU time = (12 × 10⁶ × 1.5) / (3 × 10⁹) = 6 × 10⁻³ s = 6 ms.

时钟频率以 Hz 表示;若 CPI = 1.5、指令数 1200 万、时钟频率 3 GHz,则 CPU 时间 = (12×10⁶ × 1.5) / (3×10⁹) = 6×10⁻³ 秒 = 6 毫秒。

Performance relative to a reference machine or the number of instructions per second (MIPS) can also be derived:

相对于参考机器的性能或每秒百万指令数(MIPS)也可导出:

MIPS = Clock rate / (CPI × 10⁶)


4. Binary Arithmetic & Number Systems | 二进制运算与数制

In two’s complement representation, an n-bit integer has a range from -2⁽ⁿ⁻¹⁾ to 2⁽ⁿ⁻¹⁾ – 1. For example, with 8 bits, range is -128 to 127.

在二进制补码表示中,n 位整数的范围为 -2⁽ⁿ⁻¹⁾ 到 2⁽ⁿ⁻¹⁾ – 1。例如 8 位时,范围是 -128 到 127。

Two’s complement range: -2⁽ⁿ⁻¹⁾ ≤ x ≤ 2⁽ⁿ⁻¹⁾ – 1

Binary addition follows the rules 0+0=0, 0+1=1, 1+0=1, 1+1=0 carry 1. Overflow occurs when the result exceeds the representable range.

二进制加法遵循 0+0=0, 0+1=1, 1+0=1, 1+1=0 进位 1。当结果超出表示范围时发生溢出。

For binary fractions, the place values are 2⁻¹, 2⁻², 2⁻³ etc. Thus 0.101₂ = 1×2⁻¹ + 0×2⁻² + 1×2⁻³ = 0.5 + 0.125 = 0.625.

二进制小数的位权为 2⁻¹, 2⁻², 2⁻³ 等。因此 0.101₂ = 1×2⁻¹ + 0×2⁻² + 1×2⁻³ = 0.5 + 0.125 = 0.625。


5. Boolean Algebra Laws & Simplification | 布尔代数定律与化简

Boolean algebra manipulates logic expressions. Variables take values 0 or 1. The basic operations are AND (·), OR (+), and NOT (¬). De Morgan’s laws are vital for simplification.

布尔代数处理逻辑表达式,变量取值为 0 或 1。基本运算有与 (·)、或 (+)、非 (¬)。德摩根定律对化简至关重要。

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)
De Morgan: ¬(A + B) = ¬A · ¬B ; ¬(A · B) = ¬A + ¬B

These laws allow reducing complex circuits. Example: ¬(A + B) using De Morgan becomes ¬A · ¬B, which can be implemented with NAND gates.

这些定律可用于简化复杂电路。例如,将 ¬(A + B) 用德摩根律变为 ¬A · ¬B,即可用与非门实现。


6. Logic Gate Expressions & Truth Tables | 逻辑门表达式与真值表

Logic gates are the building blocks of digital circuits. Each gate has a Boolean expression and a corresponding truth table showing output for every input combination.

逻辑门是数字电路的构建模块。每种门都有布尔表达式和对应的真值表,显示所有输入组合下的输出。

AND: F = A · B
OR: F = A + B
NOT: F = ¬A
NAND: F = ¬(A · B)
NOR: F = ¬(A + B)
XOR: F = A ⊕ B (F = A·¬B + ¬A·B)

For a 2-input XOR, the truth table output is 1 only when inputs are different. It can be expressed as A ⊕ B = (A + B) · ¬(A · B).

对于二输入异或门,仅当输入不同时输出为 1。可表示为 A ⊕ B = (A + B) · ¬(A · B)。


7. Data Structures & Tree Properties | 数据结构与树的性质

Binary trees are heavily tested. The height (h) and node count (n) are related. A full binary tree has maximum nodes; a degenerate tree behaves like a linked list.

二叉树是考试重点。高度 (h) 与节点数 (n) 相互关联。满二叉树节点数最多,而退化树表现得像链表。

Minimum height (balanced): hₘᵢₙ = ⌊log₂(n)⌋ + 1
Maximum height (degenerate): hₘₐₓ = n
Maximum nodes in a full tree of height h: 2ʰ – 1
Leaf nodes in a full tree: 2⁽ʰ⁻¹⁾

For a complete binary tree stored in an array, children of node at index i are at 2i and 2i+1; its parent is at ⌊i/2⌋.

对于以数组存储的完全二叉树,索引 i 处节点的子节点在 2i 和 2i+1;父节点在 ⌊i/2⌋。


8. Algorithm Complexity & Time Formulas | 算法复杂度与时间公式

Complexity analysis describes how runtime or space grows with input size n. Big-O notation captures the dominant term.

复杂度分析描述运行时间或空间随输入规模 n 的增长方式,大 O 记法捕获主导项。

Constant: O(1)
Logarithmic: O(log n)
Linear: O(n)
Linearithmic: O(n log n)
Quadratic: O(n²)
Exponential: O(2ⁿ)

For bubble sort, worst-case comparisons = n(n-1)/2 ⇒ O(n²). Binary search takes at most ⌊log₂(n)⌋+1 comparisons ⇒ O(log n).

冒泡排序最坏比较次数 = n(n-1)/2 ⇒ O(n²)。二分查找最多需 ⌊log₂(n)⌋+1 次比较 ⇒ O(log n)。


9. Network Transmission & Delay | 网络传输与延迟

Data travel time comprises transmission, propagation, queuing, and processing delays. Bandwidth and distance are key factors.

数据传输时间包括传输延迟、传播延迟、排队延迟和处理延迟。带宽和距离是关键因素。

Transmission delay = Data size (bits) / Bandwidth (bps)
Propagation delay = Distance / Propagation speed
Total delay = T_trans + T_prop + T_queue + T_proc

Example: sending 10 MB over a 100 Mbps link takes transmission delay = (10 × 8 × 10⁶) / (100 × 10⁶) = 0.8 s. Propagation over 200 km (speed 2×10⁸ m/s) adds 1 ms.

示例:通过 100 Mbps 链路发送 10 MB,传输延迟 = (10×8×10⁶) / (100×10⁶) = 0.8 秒。200 km 距离、传播速度 2×10⁸ m/s 增加 1 毫秒。


10. Database Cardinality & Selectivity | 数据库基数与选择度

In query optimisation, cardinality refers to the number of distinct values in an attribute, while selectivity measures the fraction of rows satisfying a condition.

在查询优化中,基数指属性中不同值的数量,而选择度衡量满足条件的行所占比例。

Selectivity = Number of qualifying rows / Total number of rows
Cardinality ratio for an index = Distinct values / Total rows

High selectivity (close to 1) often favours index usage; low selectivity may still lead to a full table scan.

高选择度(接近 1)通常有利于索引使用;低选择度则可能导致全表扫描。


11. Encryption & Hashing | 加密与哈希

RSA encryption uses modular exponentiation. Key generation relies on two large primes and their Euler totient φ(n).

RSA 加密使用模幂运算,密钥生成依赖于两个大素数及其欧拉函数 φ(n)。

n = p × q
φ(n) = (p-1)(q-1)
Choose e such that 1 < e < φ(n) and gcd(e, φ(n)) = 1
Compute d where e·d ≡ 1 (mod φ(n))
Encrypt: c = mᵉ mod n
Decrypt: m = cᵈ mod n

A cryptographic hash function h = H(m) must be one-way and collision-resistant. Password storage frequently uses salted hashes: stored = hash(password + salt).

密码哈希函数 h = H(m) 必须是单向且抗碰撞的。密码存储常使用加盐哈希:stored = hash(密码 + 盐)。


12. Compression Ratios | 压缩比

Compression reduces file size. The compression ratio quantifies the degree of reduction; space saving is complementary.

压缩可减小文件大小。压缩比量化了缩减程度,空间节省为其补数。

Compression ratio = Original size / Compressed size
Space saving = 1 – (Compressed size / Original size), often expressed as a percentage

For example, a 50 KB file compressed to 20 KB gives a compression ratio of 2.5 : 1 and a space saving of 60%.

例如,将 50 KB 文件压缩到 20 KB,压缩比为 2.5:1,空间节省 60%。

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