Skip to content

2029–2031 edition · for exams from June 2029. Students sitting exams up to November 2028 follow the current course.

2210 · 04782029–2031 editionPaper 1 · Computer Systems and Logic§1.1, §1.2, §1.3

1. Data representation and logic gates

How everything inside a computer is binary: logic gates, storage units, denary/binary/hex, binary addition, logical and cyclic shifts, two's complement, text, sound and images, and compression including Huffman coding.

What you need to know332 learning objectives, as printed in the syllabus

  1. 1.1Number systems and logic gatesChanged2026–2028 syllabus: §1.1, §10

    Adds logic gate symbols and functions, cyclic shifts and the command word Convert; binary limited to 12 bits; PiB and EiB removed.

    Learning objectives (17)
    • 1.1.1Know that computers internally represent all data in binary
    • 1.1.2Know that data is converted to binary, processed using logic gates
    • 1.1.3Identify and use the standard symbols for logic gates
    • 1.1.4Demonstrate the function of each logic gate limited to: (a) NOT; (b) AND; (c) OR; (d) NAND; (e) NOR; (f) XOR
    • 1.1.5Know how data storage is measured, limited to: (a) bit; (b) nibble; (c) byte; (d) kibibyte (KiB); (e) mebibyte (MiB); (f) gibibyte (GiB); (g) tebibyte (TiB)
    • 1.1.6Convert between each data storage measurement in 1.1.5
    • 1.1.7Know the base of the denary, binary and hexadecimal number systems
    • 1.1.8Convert between: (a) denary and binary; (b) denary and hexadecimal; (c) hexadecimal and binary
    • 1.1.9Explain the advantages of using hexadecimal as an understandable representation of binary and identify examples where hexadecimal is used
    • 1.1.10Add two positive 8-bit binary integers
    • 1.1.11Describe overflow and how it can create errors in binary addition
    • 1.1.12Perform logical left and right shifts of multiple places on a positive 8-bit binary integer
    • 1.1.13Explain the effects of logical left and right shifts
    • 1.1.14Perform cyclic left and right shifts of multiple places on a positive 8-bit binary integer
    • 1.1.15Explain the effects of cyclic left and right shifts
    • 1.1.16Convert positive and negative binary or denary integers to their two's complement 8-bit representation
    • 1.1.17Convert two's complement 8-bit integers back to binary or denary

    Logic gates will be limited to a maximum of two inputs

    Conversions in both directions, positive integers only, maximum binary number length of 12 bits

  2. 1.2Text, sound and imagesChanged2026–2028 syllabus: §1.2

    Same ideas; file-size calculations for images and sound are no longer required.

    Learning objectives (10)
    • 1.2.1Know that computers store characters as binary numbers
    • 1.2.2Understand that a character set is a set of characters that have corresponding numeric codes
    • 1.2.3Describe how a computer represents text using character sets
    • 1.2.4Describe the features of the character sets: (a) American Standard Code for Information Interchange (ASCII); (b) Unicode
    • 1.2.5Describe the advantages and disadvantages of: (a) ASCII; (b) Unicode
    • 1.2.6Describe how a computer represents analogue sound, including: (a) sample rate; (b) sample resolution
    • 1.2.7Explain the effects of changing the sample rate and sample resolution
    • 1.2.8Know that a bitmap image is made up of pixels
    • 1.2.9Describe how a computer uses binary to represent a bitmap image, including: (a) resolution; (b) colour depth
    • 1.2.10Explain the effects of changing the resolution or the colour depth on a bitmap image
  3. 1.3Data compressionChanged2026–2028 syllabus: §1.3

    Adds Huffman coding as a lossless method (no Huffman trees); file-size calculations removed.

    Learning objectives (5)
    • 1.3.1Explain the purpose of data compression for transmission and storage
    • 1.3.2Explain the impact of data compression for transmission and storage
    • 1.3.3Explain how images, sound and video files are compressed using lossy compression methods
    • 1.3.4Explain how text, images, video and sound files are compressed using the lossless compression methods of run length encoding (RLE) and Huffman coding
    • 1.3.5Describe the advantages and disadvantages of lossy and lossless compression methods and identify where each method would be appropriate from a given scenario

    Candidates will not be required to create or interpret a Huffman tree

Objectives quoted from the 2029–2031 syllabus, Version 1, September 2026; © Cambridge University Press & Assessment.

Notes3every learning objective explained, with worked examples

1.1Number systems and logic gates

Everything a computer stores or processes — numbers, text, sound, pictures, instructions — is held as binary and processed by logic gates. This section gives you the number systems (binary, denary, hexadecimal), the six logic gates, storage units, binary addition and overflow, shifts and two's complement. It is the most calculation-heavy part of Paper 1, so practise the methods until they are automatic.

Why computers use binary

A computer is built from millions of tiny switches (transistors). Each switch has only two states: on or off, so it can store one binary digit (bit): 1 or 0.

  • All data — numbers, characters, sound samples, pixel colours and program instructions — must be converted to binary before the computer can store or process it.
  • The binary data is then processed using logic gates: circuits that take one or two binary inputs and give one binary output.
  • Two states are easy to tell apart reliably, even with electrical noise, which is why binary (not denary) is used inside the hardware.

Logic gates: symbols and functions

You must recognise and draw the standard symbol for each gate and know its truth table. Gates in this section have at most two inputs.

GateWhat the output doesTruth table (A B → X)
NOTInverts its single input0 → 1, 1 → 0
AND1 only when both inputs are 100→0, 01→0, 10→0, 11→1
OR1 when at least one input is 100→0, 01→1, 10→1, 11→1
NANDNOT AND: 0 only when both inputs are 100→1, 01→1, 10→1, 11→0
NORNOT OR: 1 only when both inputs are 000→1, 01→0, 10→0, 11→0
XOR1 when the inputs are different00→0, 01→1, 10→1, 11→0

Symbol shapes: NOT is a triangle with a small circle (the bubble) at its point; AND has a flat back and a round front (D-shape); OR has a curved back and a pointed front; XOR is an OR with an extra curved line behind the back. NAND and NOR are AND and OR with a bubble on the output.

The same truth tables in Python, where &, |, ^ work on single bits:

for a in (0, 1):
    for b in (0, 1):
        print(a, b, 'AND', a & b, 'OR', a | b, 'XOR', a ^ b,
              'NAND', 1 - (a & b), 'NOR', 1 - (a | b))

Measuring data storage

UnitSize
bitone binary digit, 0 or 1
nibble4 bits
byte8 bits
kibibyte (KiB)1024 bytes (2¹⁰)
mebibyte (MiB)1024 KiB (2²⁰ bytes)
gibibyte (GiB)1024 MiB (2³⁰ bytes)
tebibyte (TiB)1024 GiB (2⁴⁰ bytes)

Converting: going to a smaller unit, multiply; going to a bigger unit, divide. Bits ↔ bytes uses 8; every step from bytes up uses 1024.

  • 3 GiB in MiB: 3 × 1024 = 3072 MiB
  • 4 KiB in bits: 4 × 1024 = 4096 bytes; 4096 × 8 = 32 768 bits
  • 2 097 152 bytes in MiB: 2 097 152 ÷ 1024 = 2048 KiB; 2048 ÷ 1024 = 2 MiB
  • 6 nibbles = 24 bits = 3 bytes

Denary, binary and hexadecimal

The base is how many different digits a number system uses.

  • Denary — base 10, digits 0–9.
  • Binary — base 2, digits 0 and 1. Place values (right to left): 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048.
  • Hexadecimal — base 16, digits 0–9 then A=10, B=11, C=12, D=13, E=14, F=15. One hex digit = exactly one nibble (4 bits).

In the exam binary numbers are at most 12 bits long and conversions use positive integers only.

Worked conversions

Denary → binary (156): write the place values and take away the largest that fits.

1286432168421
10011100

156 − 128 = 28, 28 − 16 = 12, 12 − 8 = 4, 4 − 4 = 0 → 10011100.

Binary → hex: split into nibbles from the right: 1001 1100 → 9 and 12 → 9C.

Hex → binary (B7): B = 1011, 7 = 0111 → 10110111.

Hex → denary (B7): 11 × 16 + 7 = 183.

Denary → hex (183): 183 ÷ 16 = 11 remainder 7 → B and 7 → B7.

12-bit example: 2748 = 1010 1011 1100 → hex ABC (10 × 256 + 11 × 16 + 12 = 2748).

Check any answer in Python:

print(bin(156), hex(156), int('10110111', 2), int('B7', 16))
# 0b10011100 0x9c 183 183

Why hexadecimal is used

Hexadecimal is a human-friendly way of writing binary — the computer still stores binary.

  • It is shorter: 12 binary digits become 3 hex digits, so it is easier to read and remember.
  • There are fewer mistakes when people read, copy or type it.
  • It converts to and from binary easily — each hex digit is one nibble.

Where it is used: colour codes in HTML/CSS (#FF0000 is red), MAC addresses (00:1A:2B:3C:4D:5E), IPv6 addresses, memory addresses and error codes, and showing memory contents in a debugger.

Adding two 8-bit binary integers

Add column by column from the right, carrying like denary:

Sum in a columnWriteCarry
0 + 000
0 + 110
1 + 101
1 + 1 + 1 (with carry)11

Example: 01101101 (109) + 01011011 (91)

  carry  1 1 1 1 1 1 1
         0 1 1 0 1 1 0 1   (109)
       + 0 1 0 1 1 0 1 1   (91)
       = 1 1 0 0 1 0 0 0   (200)

Check: 109 + 91 = 200 and 11001000 = 128 + 64 + 8 = 200.

Overflow

An 8-bit register can hold 0 to 255. If the result of an addition is bigger than 255, a ninth bit is needed — this is an overflow error.

Example: 11001000 (200) + 01100100 (100) = 300 = 1 00101100. The register keeps only 8 bits, 00101100 = 44, so the stored answer is wrong.

  • Overflow happens because the result needs more bits than the register has.
  • The extra carry bit is lost, so the stored value is incorrect; a program using it may crash or give wrong output.
  • The CPU sets an overflow flag so the error can be detected.

Logical shifts

A logical shift moves every bit left or right by a number of places. Bits shifted off the end are lost and the empty places are filled with 0.

  • Left 2: 00010110 (22) → 01011000 (88) — each left place multiplies by 2, so 2 places = × 4.
  • Right 3: 10110000 (176) → 00010110 (22) — each right place divides by 2 (whole-number), so 3 places = ÷ 8.

Effect when bits are lost: 01100101 (101) shifted left 3 → 00101000 (40), not 808 — the 1s pushed off the left end are lost, so the result is wrong. A right shift that loses 1s off the right end loses precision (e.g. 00000111 = 7 right 1 → 00000011 = 3, not 3.5).

x = 0b00010110
print(format((x << 2) & 0xFF, '08b'))   # 01011000
print(format(0b10110000 >> 3, '08b'))   # 00010110

Cyclic (circular) shifts

In a cyclic shift nothing is lost: the bits pushed off one end come back in at the other end.

  • Cyclic left 3 of 10110010: the first three bits 101 move to the end → 10010101.
  • Cyclic right 2 of 10110010: the last two bits 10 move to the front → 10101100.

Effect: the same bits are kept in a new order, so a cyclic shift is not a multiply or divide; shifting 8 places brings back the original number. It is used where no data may be lost, e.g. in encryption and checksum calculations.

def rotl(x: int, n: int) -> int:
    n %= 8
    return ((x << n) | (x >> (8 - n))) & 0xFF

print(format(rotl(0b10110010, 3), '08b'))  # 10010101

Two's complement (8-bit)

Two's complement stores negative integers. The leftmost bit has a negative place value: −128.

−1286432168421

The range is −128 to +127. A number starting with 1 is negative; starting with 0 is positive (and is written exactly like ordinary binary).

Denary → two's complement (−45):

  1. Write +45 in 8-bit binary: 00101101
  2. Invert every bit: 11010010
  3. Add 1: 11010011

Check: −128 + 64 + 16 + 2 + 1 = −45. ✓

Two's complement → denary (11101100): −128 + 64 + 32 + 8 + 4 = −20.

Shortcut for negatives: from the right, keep every bit up to and including the first 1, then invert the rest (00101101 → 11010011).

print(format(-45 & 0xFF, '08b'))      # 11010011
v = 0b11101100
print(v - 256 if v >= 128 else v)   # -20

Exam tips

  • Show your working for conversions — draw the place-value row; method marks are often available even if one bit is wrong.
  • Give binary answers with the number of bits asked for (8-bit = pad with leading 0s).
  • For 'describe overflow' say: the result is larger than the register can hold / needs more than 8 bits, the extra bit is lost, so the stored value is wrong.
  • For a shift question state the direction, the number of places, what fills the gaps (0 for logical) and what happens to the lost bits.
  • For 'advantages of hex' give reasons about people (shorter, fewer errors, easier to read) — not that computers use hex.
  • Draw gate symbols clearly: the NOT/NAND/NOR bubble and the extra XOR line are what the mark depends on.

Mistakes that lose marks

  • Saying computers 'store data in hexadecimal' — they store binary; hex is only for humans.
  • Using 1000 instead of 1024 between bytes, KiB, MiB, GiB and TiB.
  • Forgetting the final carry and missing that an overflow happened.
  • Filling a cyclic shift with 0s, or losing bits in it — the bits wrap round.
  • Inverting the bits for a two's complement number but forgetting to add 1.
  • Mixing up NAND and NOR, or AND and OR, in a truth table.

1.2Text, sound and images

Text, sound and images are not numbers, but a computer can only store binary — so each has a way of being turned into binary. This section explains character sets (ASCII and Unicode), how sound is sampled, and how bitmap images are stored as pixels, and what happens to quality and size when you change the settings.

Characters are stored as binary numbers

A character set is a list of characters, each with its own numeric code. To store text, the computer stores the code of each character, in binary.

  • Each key press is converted to the character's code, e.g. 'A' = 65 = 01000001.
  • The codes are sequential: 'B' = 66, 'C' = 67, so text can be sorted by comparing codes.
  • When the text is displayed, the computer looks the code up in the same character set to show the right symbol. Both computers must use the same character set.
print(ord('A'), format(ord('A'), '08b'), chr(66))   # 65 01000001 B

ASCII and Unicode

ASCIIUnicode
Bits per character7 bits (often stored in a byte; extended ASCII uses 8)up to 32 bits (often 16 or 32; encodings such as UTF-8 use 1–4 bytes)
Number of characters128 (256 extended)over a million possible codes
What it coversEnglish letters, digits, punctuation, control codescharacters of almost every language, symbols and emojis
Advantageeach character uses less storage, so files are smaller and faster to sendcan represent every language and emojis; one worldwide standard
Disadvantagecannot represent most languages or emojiseach character needs more bits, so files are larger

Unicode's first 128 codes are the same as ASCII, so ASCII text is still valid Unicode.

How sound is represented

Sound is an analogue wave. To store it, the computer samples the wave: it measures the amplitude (height) of the wave at regular time intervals and stores each measurement as a binary number.

  • Sample rate — how many samples are taken per second (measured in hertz, e.g. 44 100 Hz).
  • Sample resolution — the number of bits used to store each sample (e.g. 16 bits). More bits = more possible amplitude values.

The stored samples are only an approximation of the wave; the gaps between samples and the rounding of each sample lose a little detail.

Changing the sample rate and resolution

ChangeEffect on qualityEffect on file
Higher sample ratemore samples per second, so the recording is closer to the original wavelarger file
Lower sample ratedetail between samples is lost; quality dropssmaller file
Higher sample resolutioneach sample is more accurate (more amplitude levels), wider dynamic rangelarger file
Lower sample resolutionamplitudes are rounded more; sound is less accuratesmaller file

The trade-off is always quality versus file size (and so storage space and transmission time).

Bitmap images: pixels, resolution and colour depth

A bitmap image is a grid of pixels (picture elements). Each pixel is one colour, and that colour is stored as a binary code.

  • Resolution — the number of pixels in the image, given as width × height (e.g. 1920 × 1080).
  • Colour depth — the number of bits used for each pixel's colour. 1 bit gives 2 colours (black/white), 8 bits give 256 colours, 24 bits give over 16 million colours.

The file stores the colour code of every pixel in order, row by row, plus some extra data about the image (its width, height and colour depth).

Changing the resolution or colour depth

ChangeEffect on the imageEffect on file size
Higher resolutionmore pixels, so more detail and sharper when enlargedlarger
Lower resolutionfewer pixels; image looks pixelated (blocky) when enlargedsmaller
Higher colour depthmore colours possible, more realistic, smoother shadinglarger
Lower colour depthfewer colours; shades look bandedsmaller

Exam tips

  • Define sample rate as 'number of samples per second' and sample resolution as 'number of bits per sample' — learn those exact phrases.
  • For 'explain the effect' questions give BOTH the quality effect and the file size effect.
  • Colour depth is bits per pixel, not 'number of colours' — state the bits, then say what that allows.
  • ASCII vs Unicode: compare the number of characters/languages and the storage per character.

Mistakes that lose marks

  • Saying a higher sample rate makes the sound louder — it makes it more accurate.
  • Confusing resolution (number of pixels) with colour depth (bits per pixel).
  • Saying Unicode always uses 16 bits — it can use up to 32 bits per character.
  • Writing that ASCII can represent all languages.

1.3Data compression

Compression makes files smaller so they take less storage and can be sent faster. Lossy methods throw away data people will not notice; lossless methods — run length encoding (RLE) and Huffman coding — let the original be rebuilt exactly. You must be able to choose the right method for a scenario.

Purpose and impact of compression

Purpose: reduce the file size.

Impact on storage: smaller files use less storage space on a device or server, so more files fit and storage costs less.

Impact on transmission: smaller files upload and download faster, use less bandwidth and less mobile data, and stream with less buffering. Email attachments may only be sent if under a size limit.

Compressing and decompressing takes some processing time, and lossy compression lowers quality.

Lossy compression

Lossy compression permanently removes data, so the original file cannot be rebuilt exactly. It removes the data people are least likely to notice.

  • Images (e.g. JPEG): reduce the colour depth or resolution, and merge pixels of very similar colours into one colour.
  • Sound (e.g. MP3): perceptual coding removes sounds the human ear cannot hear (very high or low frequencies) and quieter sounds played at the same time as louder ones; the sample rate or resolution can also be reduced.
  • Video (e.g. MP4): compresses each frame like an image and stores only the changes between frames instead of every full frame; frame rate or resolution can be reduced.

Lossless: run length encoding (RLE)

RLE replaces a run of the same repeated value with one copy of the value and a count of how many times it repeats. It works well on data with long runs (simple images, icons) and can make data with few repeats larger.

Text: AAAABBBCCD (10 characters) → 4A 3B 2C 1D (8 symbols).

Image: a row of pixels White ×5, Black ×3, White ×2 (WWWWWBBBWW) → 5W 3B 2W.

Decompressing repeats each value by its count, giving back exactly the original.

from itertools import groupby

def rle(text: str) -> str:
    return ''.join(f'{len(list(g))}{ch}' for ch, g in groupby(text))

print(rle('AAAABBBCCD'))   # 4A3B2C1D

Lossless: Huffman coding

Huffman coding gives each character a variable-length binary code: the most frequent characters get the shortest codes, rare ones get longer codes. No code is the start of another code, so the bit stream can be decoded without gaps. (You will be given the codes — you do not need to build or read a Huffman tree.)

Example — the word BANANA: A appears 3 times, N twice, B once. Given codes:

CharacterFrequencyCode
A30
N210
B111

Encoded: B A N A N A → 11 0 10 0 10 0 → 110100100 = 9 bits. In 8-bit ASCII it would need 6 × 8 = 48 bits.

Decoding 110100100: read bits until they match a code — 11 = B, 0 = A, 10 = N, 0 = A, 10 = N, 0 = A → BANANA. Nothing is lost.

Lossy or lossless? Advantages, disadvantages and choosing

LossyLossless
Advantagesmuch smaller files; faster to send and streamoriginal file rebuilt exactly; no loss of quality
Disadvantagesdata is lost permanently; quality is lower; can't be undonefiles are not reduced as much
Use forphotos on websites, streaming music and video, video callstext documents, program code, spreadsheets, medical or legal images, anything that must be exact

In a scenario, ask: must the file be exactly the same afterwards? If yes (text, code, data, evidence) → lossless. If small size matters more and a little quality loss won't be noticed → lossy.

Exam tips

  • When explaining a method, say how it works AND that the data is (or is not) lost.
  • For RLE questions write each run as count + value in the order the data appears.
  • Huffman questions: count the bits of the encoded message and compare with 8 bits per character for ASCII if asked how much it saves.
  • For 'which method' questions justify from the scenario (e.g. 'a program file must be identical, so lossless').

Mistakes that lose marks

  • Saying lossless compression 'removes unnecessary data' — that is lossy.
  • Saying RLE always makes files smaller — with few repeats it can make them larger.
  • Giving common characters the longest Huffman codes (it is the opposite).
  • Recommending lossy compression for text or program files.

Infographics5download any diagram as PNG or SVG

Number system conversionsDenary ↔ binary ↔ hexadecimal — the routes the exam expects.Denarybase 10 · 0–9Binarybase 2 · 0,1Hexbase 16 · 0–9, A–F÷2, read remainders upadd place values 128…1group 4 bits → digiteach digit → 4 bitsdenary ↔ hex: go via binary (or ÷16 / ×16)128643216842110110110= 128+32+16+4+2= 182 = B6₁₆Two's complement: invert all bits, add 1. Left shift ×2, right shift ÷2.Hex is used for MAC addresses, colour codes, memory dumps and error codes.cswithzak.com

Number system conversions

O LevelAS
Logic gate symbols & rulesDraw these exactly. A small circle on the output means NOT (inversion).ABXAND1 only if both 1X = A.BABXOR1 if either is 1X = A+BAXNOTinverts the inputX = ĀABXNAND0 only if both 1X = (A.B)‾ABXNOR1 only if both 0X = (A+B)‾ABXXOR1 if inputs differX = A⊕Bcswithzak.com

Logic gate symbols

O LevelAS
Lossless vs lossy compressionWhy compress? Less storage, faster transmission, less bandwidth. The question is whether you can get theoriginal back.LOSSLESSoriginal restored exactly — RLE, ZIP, PNG, FLAC, GIFLOSSYdetail discarded for ever — JPEG, MP3, MP4, AACRun-length encoding (RLE)AAAABBBCCDAA4A3B2C1D2A12 → 10 bytes. RLE wins only with long runs (flat colour areas).Also: LZ (repeated patterns), Huffman (short codes, common symbols).What lossy actually removesImages (JPEG): merge near-identical colours, reduce colour depthor resolution — the eye cannot tell the difference.Sound (MP3): remove frequencies humans cannot hear, quietersounds masked by louder ones; lower sample rate / resolution.Video (MPEG): store only the changes between frames.Result: much smaller files, but quality is permanently lower.LosslessLossyData lost?none — bit-for-bit identical after decompressionyes — cannot recover the originalCompression ratiolower (depends on the data)much higher (adjustable quality)Use whentext, programs, spreadsheets, medical imagesphotos, music, streaming videoExam tip: if the question says “the file must be restored exactly” → lossless; “smallest possible for the web” → lossy.cswithzak.com

Lossless vs lossy compression

ASO Level
Logical and cyclic shiftsA shift moves every bit left or right by a number of places. Logical shifts lose the bits that fall offand fill with 0s; cyclic shifts wrap them round.Original10110110denary 182Logical left 21101100010 lost · 0s in · overflowLogical right 20010110110 lost · 0s in · 182 ÷ 4 → 45Cyclic left 21101101010 leaves left, re-enters rightCyclic right 1010110110 leaves right, re-enters leftLogical left shift by n = × 2ⁿ while no 1 falls off the left; a 1 lost on the left = overflow (wrong answer).Logical right shift by n = ÷ 2ⁿ, rounded down; bits lost on the right make the answer less precise.Cyclic (circular) shift: nothing is lost — the bits pushed out of one end come back in at the other end.Exam tip: write the register before and after, mark which bits left the register, and say what filled the gap.cswithzak.com

Logical and cyclic shifts

O Level
Huffman coding (lossless)Common characters get short codes, rare ones long codes. No code is the start of another, so the bitstream decodes one way only.Text: ABRACADABRA (11 characters)CharFrequencyCodeBitsA505 × 1 = 5B2102 × 2 = 4R21102 × 3 = 6C111101 × 4 = 4D111111 × 4 = 4Total = 23 bits vs 11 × 8 = 88 bits in 8-bit ASCIIEncoding: A B R A …0 10 110 0 …→ 0101100 …Decoding: read until a code matches0 = A ✓ then 1 … 10 = B ✓ then 1 … 11 … 110 = R ✓works because no code is a prefix of another1 Count how often each character appears.2 Give the most frequent characters the shortest codes (here A = 0).3 The code table must be stored or sent with the file, or it cannot be decoded.Run-length encoding (RLE) suits long runs of the same value; Huffman suits uneven character frequencies.Both RLE and Huffman are lossless: the original data is restored exactly.cswithzak.com

Huffman coding

O Level

Python for this topic2Python 3.10+, the only language on Paper 2 — runs in your browser

Key terms16use these exact words in the exam

Test yourself

Check you know the 2029–2031 content

Written for the new syllabus only: every card and question traces to a learning objective above. Rounds are random, and marks earn XP on your dashboard.

4 decks · 69 cards · 19 quiz questions.

From the current course

Most of this topic is taught in the 2026–2028 course today. Its notes and past-paper questions still help — skip anything the 2029–2031 syllabus removed (see the notes above).

Enroll nowOnline classes