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

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

This handbook compiles the key formulas required for the WJEC A-Level Computer Science specification, covering data representation, file sizes, transmission, logic, and processor performance. Each formula is presented with a concise explanation and a worked example where appropriate, helping you to memorise and apply them effectively in examinations.

本手册汇编了 WJEC A-Level 计算机科学课程所需的关键公式,涵盖数据表示、文件大小、传输、逻辑和处理器性能等主题。每个公式都配有简明解释和适当示例,助你牢记并在考试中有效运用。

1. Text File Size | 文本文件大小

The size of a plain text file in bytes is directly proportional to the number of characters it contains. In standard ASCII encoding, each character uses 7 bits (commonly stored in a single byte); extended ASCII and UTF-8 may use one or more bytes per character. For exam purposes, assume 1 byte per character unless stated otherwise.

纯文本文件的字节大小与其包含的字符数成正比。在标准 ASCII 编码中,每个字符使用 7 位(通常存储为 1 个字节);扩展 ASCII 和 UTF-8 可能使用 1 个或多个字节。考试中除非另有说明,假设每个字符占用 1 字节。

File Size (bytes) = Number of Characters × Bytes per Character

文件大小(字节)= 字符数 × 每字符字节数

For a text file containing 20,000 characters encoded in ASCII, the file size is 20,000 × 1 = 20,000 bytes (or 20 KB).

一个包含 20,000 个 ASCII 字符的文本文件,其大小为 20,000 × 1 = 20,000 字节(即 20 KB)。


2. Uncompressed Image File Size | 未压缩图像文件大小

An uncompressed bitmap image stores colour data for each pixel. Its total size depends on the resolution (width × height in pixels) and the colour depth (number of bits used to represent the colour of a single pixel). The result in bits is divided by 8 to give bytes.

未压缩位图图像为每个像素存储颜色数据。其总大小取决于分辨率(宽度×高度,以像素计)和颜色深度(用于表示单个像素颜色的位数)。以位为单位的结果除以 8 即可得到字节数。

Image Size (bytes) = (Width × Height × Colour Depth) / 8

图像大小(字节)=(宽度 × 高度 × 颜色深度)/ 8

An 800 × 600 pixel image with 24-bit colour depth uses (800 × 600 × 24) / 8 = 1,440,000 bytes ≈ 1.44 MB.

一幅 800×600 像素、24 位颜色深度的图像占用 (800 × 600 × 24) / 8 = 1,440,000 字节 ≈ 1.44 MB。


3. Uncompressed Sound File Size | 未压缩声音文件大小

Digital audio is created by sampling an analogue signal. The size of an uncompressed sound file is influenced by the sample rate, the sample resolution (bit depth), the number of channels, and the duration of the recording.

数字音频通过对模拟信号进行采样而创建。未压缩声音文件的大小受采样率、采样分辨率(位深)、声道数和录音时长的影响。

Sound Size (bytes) = Sample Rate × Sample Resolution × Channels × Duration (seconds)

声音大小(字节)= 采样率 × 采样分辨率 × 声道数 × 时长(秒)

If the sample rate is given in Hz and resolution in bits, the formula yields the size in bits. Divide by 8 to convert to bytes. For a 10-second stereo recording at 44.1 kHz with 16-bit resolution, the size is 44,100 × 16 × 2 × 10 = 14,112,000 bits = 1,764,000 bytes.

若采样率以 Hz 为单位、分辨率以位为单位,公式得出的大小单位为位。除以 8 可转换为字节。一段 10 秒立体声录音,采样率 44.1 kHz、16 位分辨率,大小为 44,100 × 16 × 2 × 10 = 14,112,000 位 = 1,764,000 字节。


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

When sending a file over a network, the time required depends on the file size and the bandwidth (or bit rate) of the connection. Both quantities must be expressed in the same unit (bits or bytes).

通过网络发送文件时,所需时间取决于文件大小和连接的带宽(或比特率)。两个量必须使用相同的单位(位或字节)。

Transfer Time (seconds) = File Size (bits) / Bit Rate (bits per second)

传输时间(秒)= 文件大小(位)/ 比特率(位/秒)

If a 100 megabit file is transferred over a 50 Mbps connection, the minimum transfer time is 100 / 50 = 2 seconds, ignoring overheads.

如果一个 100 兆位(Mb)的文件通过 50 Mbps 的连接传输,最短传输时间为 100 / 50 = 2 秒(忽略开销)。


5. Compression Ratio | 压缩比

Compression techniques reduce file size for storage or transmission. The compression ratio compares the original size to the compressed size. A higher ratio indicates greater size reduction.

压缩技术可减小文件大小以便存储或传输。压缩比将原始大小与压缩后大小进行比较。比值越高表示尺寸缩减越大。

Compression Ratio = Original Size / Compressed Size

压缩比 = 原始大小 / 压缩后大小

Alternatively, the space saving percentage can be calculated as: Space Saving (%) = (1 − (Compressed Size / Original Size)) × 100%.

或者,空间节省百分比可计算为:节省空间 (%) = (1 − (压缩后大小 / 原始大小)) × 100%。

An image that originally occupies 4 MB and is compressed to 1 MB has a compression ratio of 4 : 1, and a space saving of 75%.

一幅原占 4 MB 的图像压缩至 1 MB,压缩比为 4:1,节省了 75% 的空间。


6. Sampling and the Nyquist Theorem | 采样与奈奎斯特定理

To accurately reconstruct an analogue signal from its digital samples, the sampling theorem states that the sample rate must be at least twice the highest frequency present in the signal. This minimum rate is called the Nyquist rate.

为了从数字样本中准确重建模拟信号,采样定理规定采样率必须至少是信号中最高频率的两倍。该最低采样率称为奈奎斯特率。

Sample Rate (Hz) ≥ 2 × Maximum Signal Frequency (Hz)

采样率 (Hz) ≥ 2 × 最大信号频率 (Hz)

If an audio signal contains frequencies up to 20 kHz, the Nyquist rate is 40 kHz. This explains why CD-quality audio uses a sample rate of 44.1 kHz (slightly above the Nyquist rate).

如果音频信号包含高达 20 kHz 的频率,奈奎斯特率为 40 kHz。这解释了为何 CD 音质使用 44.1 kHz 的采样率(略高于奈奎斯特率)。


7. Processor Performance Indicators | 处理器性能指标

The execution speed of a CPU can be described using clock speed, cycles per instruction (CPI), and the number of instructions per second (MIPS). These relationships help compare processor performance.

CPU 的执行速度可以用时钟速度、每条指令周期数 (CPI) 和每秒百万条指令数 (MIPS) 来描述。这些关系有助于比较处理器性能。

Time per Instruction Cycle = 1 / Clock Frequency

每条指令周期时间 = 1 / 时钟频率

Execution Time (seconds) = Instruction Count × CPI × Clock Cycle Time

执行时间(秒)= 指令数 × CPI × 时钟周期时间

MIPS = (Clock Frequency (Hz) / CPI) / 10⁶

MIPS = (时钟频率 (Hz) / CPI) / 10⁶

A 2 GHz processor with average CPI = 0.5 can achieve 4,000 MIPS (2×10⁹ / 0.5 / 10⁶).

一个 2 GHz 的处理器,平均 CPI = 0.5,可达 4,000 MIPS (2×10⁹ / 0.5 / 10⁶)。


8. Binary Number Range | 二进制数范围

In computer systems, the range of values that can be represented using a fixed number of bits depends on whether the interpretation is unsigned or two’s complement signed binary.

在计算机系统中,用固定位数可表示的数值范围取决于解释为无符号数还是二进制补码有符号数。

Unsigned n-bit: 0 to 2ⁿ − 1

n 位无符号数:0 到 2ⁿ − 1

Signed (Two’s complement) n-bit: −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1

n 位有符号数(二进制补码):−2ⁿ⁻¹ 到 2ⁿ⁻¹ − 1

For an 8-bit register, unsigned numbers range from 0 to 255, while signed numbers range from −128 to +127.

对于 8 位寄存器,无符号数范围为 0 至 255,有符号数范围为 −128 至 +127。


9. Floating-Point Representation | 浮点表示

Binary floating-point numbers store a value in the form mantissa × 2^exponent, allowing a wide range of values with limited bits. Normalisation ensures maximum precision by adjusting the mantissa so that the most significant bit is 1 (for positive numbers) or 0 (for negative numbers).

二进制浮点数将数值以 尾数 × 2^指数 的形式存储,从而在有限位数下表示极广的数值范围。通过调整尾数使最高有效位为 1(正数)或 0(负数),规格化可确保最大精度。

Value = Mantissa × 2^Exponent

数值 = 尾数 × 2^指数

When normalising, shift the binary point and adjust the exponent accordingly, checking for overflow or underflow within the allocated bits.

进行规格化时,移动二进制小数点并相应调整指数,同时检查是否超出所分配位数的溢出或下溢。


10. Boolean Algebra Laws & Identities | 布尔代数定律与恒等式

Boolean algebra provides a set of rules to simplify logic expressions, which is essential for designing and minimising logic circuits. The following identities use AND (⋅), OR (+), and NOT (overbar or prime).

布尔代数提供了一套简化逻辑表达式的规则,这对设计和最小化逻辑电路至关重要。以下恒等式使用 AND (⋅)、OR (+) 和 NOT(上划线或撇号)。

Identity: A + 0 = A ; A ⋅ 1 = A

恒等律:A + 0 = A ; A ⋅ 1 = A

Annulment: A + 1 = 1 ; A ⋅ 0 = 0

归零律:A + 1 = 1 ; A ⋅ 0 = 0

Idempotent: A + A = A ; A ⋅ A = A

幂等律:A + A = A ; A ⋅ A = A

Complement: A + ¬A = 1 ; A ⋅ ¬A = 0

互补律:A + ¬A = 1 ; A ⋅ ¬A = 0

Double Negation: ¬(¬A) = A

双重否定律:¬(¬A) = A

De Morgan’s Laws: ¬(A ⋅ B) = ¬A + ¬B ; ¬(A + B) = ¬A ⋅ ¬B

德摩根定律:¬(A ⋅ B) = ¬A + ¬B ; ¬(A + B) = ¬A ⋅ ¬B

Absorption rules, such as A + (A ⋅ B) = A, also frequently appear in simplification exercises.

吸收律,如 A + (A ⋅ B) = A,也常出现在化简练习中。


11. Parity Bits and Hamming Distance | 奇偶校验位与汉明距离

A parity bit is added to a binary string to make the total number of 1-bits either even (even parity) or odd (odd parity). The parity bit value is determined by XOR operations over all data bits.

奇偶校验位被附加到二进制串上,使 1 位的总数为偶数(偶校验)或奇数(奇校验)。校验位的值由所有数据位的异或运算决定。

Even Parity Bit = b₁ ⊕ b₂ ⊕ … ⊕ bₙ

偶校验位 = b₁ ⊕ b₂ ⊕ … ⊕ bₙ

Hamming distance is the number of bit positions in which two binary words differ. Error-correcting codes rely on minimum Hamming distance to detect and correct errors.

汉明距离是两个二进制字对应位不同的位数。纠错码依赖最小汉明距离来检测和纠正错误。

The minimum number of bit flips needed to change one valid codeword into another is the code’s Hamming distance.

将一个有效码字变成另一个有效码字所需的最少位翻转次数,即为该编码的汉明距离。


12. Hamming Code Redundancy | 汉明码冗余度

Hamming codes use additional parity bits to enable single-error correction. To protect m data bits, a number r of redundant (parity) bits must be chosen such that all single-bit errors can be uniquely identified.

汉明码使用额外的奇偶校验位来实现单错纠正。为了保护 m 个数据位,必须选择 r 个冗余(校验)位,使得所有单比特错误都能被唯一识别。

2^r ≥ m + r + 1

2^r ≥ m + r + 1

Where m is the number of data bits and r is the number of parity bits. For example, 4 data bits require at least 3 parity bits since 2³ = 8 ≥ 4 + 3 + 1 = 8.

其中 m 为数据位数,r 为校验位数。例如,4 个数据位至少需要 3 个校验位,因为 2³ = 8 ≥ 4 + 3 + 1 = 8。


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