A Level Computer Science 9618 — all 20 sections, free.
A complete study guide for Cambridge International AS & A Level Computer Science 9618, covering all 20 syllabus sections and all 44 sub-sections for exams in 2027, 2028 and 2029.
Sitting exams in 2026? Cambridge states there are no significant changes which affect teaching in this version, so this guide covers the earlier cycle too — but confirm your exam year with your school.
Sections 1–12 are AS Level (Papers 1 and 2). Sections 13–20 are A2 (Papers 3 and 4). One thing to internalise on day one: calculators are not allowed in any paper, so every binary, hexadecimal and floating-point conversion has to be done by hand.
📄 20 plain-English chapter handouts →✎ Practice & self-test →
The papers
| Paper | Length & marks | Covers | Weight |
|---|---|---|---|
| Paper 1 Theory Fundamentals | 1 h 30 min · 75 marks | Sections 1–8. Written paper, all questions answered. | 50% of AS 25% of A Level |
| Paper 2 Fundamental Problem-solving and Programming Skills | 2 h · 75 marks | Sections 9–12. Answers written in pseudocode. | 50% of AS 25% of A Level |
| Paper 3 Advanced Theory | 1 h 30 min · 75 marks | Sections 13–20. Written paper. | 25% of A Level |
| Paper 4 Practical | 2 h 30 min · 75 marks | Sections 19–20, except low-level and declarative programming. Done on a computer with no internet. You submit complete program code and evidence of testing, in Java, VB.NET or Python (console mode). | 25% of A Level |
Three routes. AS Level only = Papers 1 and 2. A Level staged over two years = Papers 1 and 2 in year 1, Papers 3 and 4 in year 2. A Level in one series = all four papers.
1 · Information representation
1.1Data representation
Know denary, binary, hexadecimal and binary coded decimal (BCD), and convert freely between them. Understand why hexadecimal is used — one hex digit is exactly four bits, so it is a compact, human-readable shorthand for binary in MAC addresses, colour codes, memory dumps and error codes.
Two's complement represents signed integers: to negate, invert every bit and add one. An n-bit two's complement number covers −2n−1 to +2n−1 − 1, so 8 bits covers −128 to +127.
Character sets: ASCII uses 7 bits (128 characters), extended ASCII 8 bits; Unicode uses more bits per character so it can represent every writing system, at the cost of larger files.
Represent −37 in 8-bit two's complement.
- +37 in binary: 32 + 4 + 1 = 0010 0101.
- Invert every bit: 1101 1010.
- Add one: 1101 1011.
- Check: 1101 1011 as unsigned is 219, and 219 − 256 = −37 ✓
1.2Multimedia — graphics and sound
Bitmap images store a colour value per pixel: resolution is the number of pixels, colour depth is the bits per pixel. Enlarging a bitmap causes pixellation. Vector images store a list of drawing objects with properties, so they scale without loss of quality and are usually much smaller — but they are unsuitable for photographs.
Sound is captured by sampling: the sampling rate is samples per second, the sampling resolution is bits per sample. Higher values give a more accurate reproduction and a larger file.
(a) A bitmap is 800 × 600 pixels with 24-bit colour. (b) A 30-second mono sound clip is sampled at 44 100 Hz with 16-bit resolution.
- (a) 800 × 600 = 480 000 pixels × 24 bits = 11 520 000 bits = 1 440 000 bytes ≈ 1.37 MiB.
- (b) 44 100 × 16 × 30 = 21 168 000 bits = 2 646 000 bytes ≈ 2.52 MiB.
Always state the unit you have used and whether you divided by 1024 or 1000. Show the working — the marks are on the method, and there is no calculator.
1.3Compression
Lossless compression allows the original file to be reconstructed exactly — run-length encoding, and dictionary methods used in ZIP and PNG. Essential for text, program code and spreadsheets. Lossy compression discards data permanently — JPEG, MP3 — giving far smaller files, acceptable for photographs and music where small losses are imperceptible.
2 · Communication
2.1Networks including the internet
LAN covers a small geographic area under one organisation's control; WAN spans large distances using third-party infrastructure. Topologies: bus, star, mesh, hybrid — know an advantage and a disadvantage of each.
Hardware: a switch forwards frames only to the destination port using MAC addresses; a router connects different networks and forwards packets using IP addresses; a NIC gives a device its MAC address; a server provides services to clients.
Client–server centralises data and control, which makes backup and security easier but creates a single point of failure. Peer-to-peer shares resources directly between equal machines, with no central server.
The internet: IP addressing (IPv4 is 32-bit and running out; IPv6 is 128-bit), public versus private IP addresses, static versus dynamic addressing, URL structure, and the DNS which translates domain names into IP addresses. Understand the difference between the internet (the global network infrastructure) and the World Wide Web (a service running on it).
3 · Hardware
3.1Computers and their components
The von Neumann model: a processor, a single memory holding both data and instructions, and buses. Primary storage — RAM (volatile, working memory) and ROM (non-volatile, holds the bootstrap). Secondary storage — HDD (magnetic), SSD (flash, no moving parts, faster, more shock-resistant), optical discs. Off-line storage for backup and archive.
Match input and output devices to applications and justify the match: a barcode scanner at a supermarket checkout, a touch screen on a self-service kiosk, a 3D printer for prototyping.
3.2Logic gates and logic circuits
| Gate | Output is 1 when… | Boolean |
|---|---|---|
| NOT | the input is 0 | Ā |
| AND | both inputs are 1 | A·B |
| OR | at least one input is 1 | A + B |
| NAND | NOT both inputs are 1 | (A·B)‾ |
| NOR | neither input is 1 | (A + B)‾ |
| XOR | the inputs are different | A ⊕ B |
Build and interpret logic circuits, produce truth tables from circuits and circuits from problem statements or truth tables.
4 · Processor fundamentals
4.1CPU architecture
Components: ALU, control unit, system clock, immediate access store, and the registers — PC (program counter, address of the next instruction), MAR (memory address register), MDR (memory data register), CIR (current instruction register), ACC (accumulator), IX (index register), SR (status register).
Buses: the address bus is unidirectional and its width sets the maximum addressable memory; the data bus is bidirectional and its width affects the amount of data moved per cycle; the control bus carries signals such as read, write and interrupt.
Factors affecting performance: clock speed, number of cores, cache size and level, bus width. Explain each in terms of why it helps — more cache means fewer slow trips to main memory, more cores means genuine parallel execution.
Interrupts: a signal that causes the processor to suspend the current program, save its state on the stack, run the appropriate interrupt service routine, then restore the state and resume. The check for interrupts happens at the end of each fetch–execute cycle.
4.2Assembly language
Assembly is a low-level language with a one-to-one relationship to machine code, translated by an assembler. Learn the addressing modes: immediate (the operand is the value), direct (the operand is an address), indirect (the operand is the address of an address), indexed (the address plus the contents of IX), and relative.
You are given an instruction set in the exam. The skill is tracing a short program with a trace table, showing the contents of the accumulator, the index register and any memory locations after each instruction.
LDM #20 loads the value 20, while LDD 20 loads the contents of address 20. Misreading the mode makes every subsequent line of the trace wrong.4.3Bit manipulation
Logical shifts move bits left or right, filling with zeros — a left shift multiplies by 2, a right shift divides by 2 (integer division). An arithmetic right shift preserves the sign bit. A cyclic shift moves the bit that falls off one end round to the other.
Bit masking uses AND to test or clear bits, OR to set bits, and XOR to toggle them — for example, AND with 0000 1111 keeps only the lower nibble.
The byte 0011 0110 (54) is shifted logically left by 2 places.
- Result: 1101 1000 = 216.
- 54 × 4 = 216 ✓ — the shift multiplied by 2² as expected.
- Shift left once more and the leading 1 is lost: 1011 0000 = 176, not 432. Overflow.
5 · System software
5.1Operating systems
The OS manages memory, files, security, input/output, processes and the user interface, and provides a virtual machine — hiding hardware complexity so that applications and users need not deal with it directly.
Utility software: disk defragmenter, backup, file compression, anti-virus, formatting. The bootstrap in ROM loads the OS from secondary storage into RAM at start-up.
5.2Language translators
| Compiler | Interpreter | Assembler | |
|---|---|---|---|
| Translates | whole program at once | line by line, each time it runs | assembly to machine code, one to one |
| Output | executable file | none saved | object code |
| Errors | full list after compilation | stops at the first error found | reports invalid mnemonics |
| Speed of execution | fast | slower | fast |
| Best for | distributing finished software | development and debugging | low-level work |
Integrated development environments support writing, editing and debugging: syntax highlighting, auto-completion, prettyprinting, breakpoints, single-stepping, variable watch windows and a report window.
6 · Security, privacy and data integrity
6.1Data security
Threats: malware (virus, worm, trojan, spyware, ransomware), hacking, phishing, pharming, and accidental damage. Protection: firewalls, authentication (passwords, biometrics, two-factor), access rights, anti-malware, encryption, physical security, backups and a disaster recovery plan.
6.2Data integrity
Validation checks that data is reasonable and is done by the computer at input: range check, format check, length check, presence check, type check, existence check, limit check and check digit. Verification checks that data has been copied or entered accurately: double entry, visual check, and — for transfer — parity checks, checksums and Automatic Repeat reQuest (ARQ).
A byte 0110100? is sent with even parity. What is the parity bit, and what does the receiver do?
- The seven data bits 0110100 contain three ones.
- Even parity means the total number of ones must be even, so the parity bit is 1, giving 01101001.
- The receiver counts the ones; an odd count means an error occurred in transmission.
- Limitation: a parity check cannot detect two bit-flips, because the parity is unchanged — which is why parity blocks and checksums are also used.
7 · Ethics and ownership
7.1Ethics and ownership
Professional ethics: the responsibilities of a computing professional — competence, honesty about capability, respect for privacy and confidentiality, avoiding harm, and acting in the public interest. Know the roles of professional bodies such as the BCS, IEEE and ACM.
Copyright and licensing: software is protected by copyright. Free software may be studied, changed and redistributed freely; open source makes the source code available under specified conditions; shareware is distributed free for a trial period; commercial software requires a paid licence. Compare their implications for the user and the developer.
8 · Databases
8.1Database concepts
Limitations of a file-based approach: data duplication, data inconsistency, data dependence on the programs, and difficulty of controlling access. A relational database solves these through a single controlled store.
Key terms: entity, table, record, field, primary key (uniquely identifies a record), candidate key, composite key (two or more fields together), secondary key (an index for fast searching), foreign key (a field that links to a primary key in another table), and referential integrity (a foreign key must match an existing primary key or be null).
Relationships are one-to-one, one-to-many or many-to-many; a many-to-many relationship is resolved with a link table. Normalisation to 3NF: 1NF removes repeating groups, 2NF removes partial dependencies on part of a composite key, 3NF removes transitive (non-key) dependencies.
8.2Database management systems
A DBMS provides a data dictionary (metadata about the database), developer interface, query processor, and tools for creating forms, reports and queries. It enforces access rights and maintains integrity, so different applications share one consistent set of data.
8.3DDL and DML
DDL defines the structure: CREATE DATABASE, CREATE TABLE, ALTER TABLE, and the constraints PRIMARY KEY, FOREIGN KEY. DML manipulates the data: SELECT, FROM, WHERE, ORDER BY, GROUP BY, INNER JOIN, SUM, COUNT, AVG, INSERT INTO, UPDATE, DELETE.
List the surname of every student and the name of their course, for students in year 13, sorted by surname.
FROM Student INNER JOIN Course ON Student.CourseID = Course.CourseID
WHERE Student.Year = 13
ORDER BY Student.Surname;
Qualify every field name with its table when two tables are involved, put the join condition in ON, and end with a semicolon. Each of those is separately marked.
9 · Algorithm design and problem-solving
9.1Computational thinking skills
Abstraction — keeping only the details relevant to the problem. Decomposition — breaking a problem into smaller sub-problems. Pattern recognition — spotting similarities that let one solution serve several cases. These are examined by asking you to apply them to an unfamiliar scenario, not to define them.
9.2Algorithms
Write and interpret algorithms as structured English, flowcharts and pseudocode, using input–process–output and the three basic constructs: sequence, selection and iteration.
Standard algorithms to know cold: linear search, binary search, bubble sort, insertion sort, and the routines for finding a total, a maximum, a minimum, a mean and a count.
DECLARE Low, High, Mid : INTEGER
Low ← 1
High ← 100
WHILE Low <= High DO
Mid ← (Low + High) DIV 2
IF List[Mid] = Target THEN
RETURN Mid
ELSE
IF List[Mid] < Target THEN
Low ← Mid + 1
ELSE
High ← Mid - 1
ENDIF
ENDIF
ENDWHILE
RETURN -1 // not found
ENDFUNCTION
Binary search requires a sorted list — state that whenever you propose it. It takes at most ⌈log₂ n⌉ comparisons, so 1000 items need at most 10, against 1000 for a linear search.
10 · Data types and structures
10.1Data types and records
The pseudocode data types are INTEGER, REAL, CHAR, STRING, BOOLEAN and DATE. A record holds several related items of different types under one name.
DECLARE Name : STRING
DECLARE Age : INTEGER
DECLARE Grade : CHAR
ENDTYPE
DECLARE Learner : Student
Learner.Name ← "Ayesha"
10.2Arrays
An array holds many items of the same type under one identifier, accessed by index. Cambridge pseudocode declares the bounds explicitly.
DECLARE Grid : ARRAY[1:5, 1:8] OF CHAR // 2D — [row, column]
Process arrays with FOR loops; use nested FOR loops for two dimensions. You must be able to write a bubble sort and both search algorithms over an array.
DECLARE N, I : INTEGER
N ← 30
REPEAT
Swapped ← FALSE
FOR I ← 1 TO N - 1
IF Marks[I] > Marks[I + 1] THEN
Temp ← Marks[I]
Marks[I] ← Marks[I + 1]
Marks[I + 1] ← Temp
Swapped ← TRUE
ENDIF
NEXT I
N ← N - 1
UNTIL Swapped = FALSE
The Swapped flag stops the sort as soon as a full pass makes no swaps — worth explaining in any "how could this be made more efficient" question.
Marks[I + 1], so the loop must stop at N - 1. Running to N reads past the end of the array — one of the most common errors in Paper 2.10.3Files
Handle text files in pseudocode: open for READ, WRITE or APPEND, read or write a line, test for end of file, then close.
WHILE NOT EOF("Data.txt") DO
READFILE "Data.txt", LineOfText
OUTPUT LineOfText
ENDWHILE
CLOSEFILE "Data.txt"
10.4Introduction to abstract data types
| ADT | Rule | Operations |
|---|---|---|
| stack | LIFO — last in, first out | push, pop; a top pointer |
| queue | FIFO — first in, first out | enqueue, dequeue; head and tail pointers |
| linked list | each node holds data and a pointer to the next | insert, delete, traverse; a start pointer and a free list |
Understand what each is used for — a stack for storing return addresses and for undo functions, a queue for print spooling and buffers, a linked list where frequent insertion and deletion are needed without shifting data. At AS you use them and describe them with diagrams; writing the pseudocode implementation is A2 material.
11 · Programming
11.1Programming basics
Declaration and use of variables and constants, assignment, arithmetic operators (+ - * / DIV MOD ^), relational operators, logical operators (AND OR NOT), and the built-in functions for strings (LENGTH, LEFT, RIGHT, MID, LCASE, UCASE), numbers (INT, RAND) and type conversion (NUM_TO_STR, STR_TO_NUM).
11.2Constructs
Selection: IF … THEN … ELSE … ENDIF and CASE OF … OTHERWISE … ENDCASE. Iteration: FOR … NEXT (count-controlled), WHILE … ENDWHILE (pre-condition, may run zero times), REPEAT … UNTIL (post-condition, always runs at least once).
11.3Structured programming
Procedures perform a task; functions return a value and can be used inside an expression. Parameters may be passed by value (a copy — changes do not affect the caller) or by reference (the actual variable — changes do affect the caller).
Scope: a local variable exists only inside its subroutine; a global variable is accessible everywhere. Prefer local variables and parameters — they prevent accidental side effects and make modules independently testable.
Benefits of a modular approach: the problem is decomposed into manageable parts, modules can be written and tested independently and by different people, code can be reused, and maintenance is easier.
12 · Software development
12.1Program development life cycle
Analysis → design → coding → testing → maintenance. Compare the waterfall model (sequential, well documented, hard to revisit an earlier stage), iterative development (repeated cycles of refinement) and rapid application development (prototypes and user feedback, fast but with lighter documentation).
12.2Program design
Design tools: structure charts (showing the hierarchy of modules and the parameters passed between them), state-transition diagrams, flowcharts and pseudocode. Be able to read one and produce another from it.
12.3Program testing and maintenance
Types of error: syntax (breaks the rules of the language — caught by the translator), logic (runs but gives the wrong result), run-time (crashes during execution, such as division by zero).
Test data: normal (typical, should be accepted), abnormal/erroneous (should be rejected), extreme (at the limits of the valid range) and boundary (the pair of values either side of a limit — one accepted and one rejected).
Testing strategies: white-box (testing every path through the code), black-box (comparing outputs with expected outputs for given inputs), stub testing, integration testing, alpha, beta and acceptance testing. Maintenance is corrective (fixing faults), adaptive (responding to a changed environment) and perfective (improving performance or usability).
A mark must be between 0 and 100 inclusive. Give test data of each type.
- Normal: 57 — accepted.
- Extreme: 0 and 100 — both accepted.
- Abnormal: "seven" or −5 — rejected.
- Boundary: the pairs (−1, 0) and (100, 101) — one rejected and one accepted in each pair.
Boundary data always comes in pairs straddling a limit. Giving only one value of the pair is the standard half-answer.
13 · Data representation (A2)
13.1User-defined data types
Non-composite user-defined types: enumerated (a named list of possible values) and pointer (holding a memory address). Composite: record, set and class. Justify the use of a user-defined type — it makes the program self-documenting, restricts values to those that are valid, and groups related data.
TYPE TPointer = ^INTEGER // pointer to an integer
13.2File organisation and access
| Organisation | Access | Good for |
|---|---|---|
| serial | sequential only | transaction logs — records appended in order of arrival |
| sequential | sequential only | batch processing — records ordered by key |
| random (direct) | direct, via a hashing algorithm | fast retrieval of a single record |
A hashing algorithm converts a key into a storage address. A collision occurs when two keys hash to the same address; handle it with overflow areas or by linear probing to the next free slot.
13.3Floating-point numbers
A normalised positive mantissa begins 0.1; a normalised negative mantissa begins 1.0. Normalisation gives the maximum precision for the available bits and makes each value's representation unique.
The trade-off: for a fixed total number of bits, more mantissa bits give greater precision but fewer exponent bits give a smaller range. Be ready to argue that trade-off both ways.
Represent +6.5 with an 8-bit mantissa and a 4-bit exponent, both two's complement.
- 6.5 in binary is 110.1
- Move the point three places left: 0.1101 × 2³.
- Mantissa (8 bits): 0110 1000 — starts 0.1, so it is normalised.
- Exponent 3 in 4-bit two's complement: 0011.
- Answer: 0110 1000 0011.
Find the denary value of mantissa 1011 0000 with exponent 0010.
- Exponent 0010 = +2.
- The mantissa starts with 1, so it is negative. Its value is −1 + 0.011 in binary = −1 + 0.375 = −0.625.
- Value = −0.625 × 2² = −2.5.
For a two's complement mantissa the leading bit has weight −1, then 0.5, 0.25, 0.125 and so on. Getting that first weight wrong is the single biggest source of errors in this topic.
14 · Communication and internet
14.1Protocols
A protocol is an agreed set of rules for communication. Protocols are arranged in a stack of layers, each providing a service to the layer above, so that a change in one layer does not force changes in the others.
| Layer | Role | Protocols |
|---|---|---|
| application | services for the user's program | HTTP, HTTPS, FTP, SMTP, POP3, IMAP, DNS, BitTorrent |
| transport | end-to-end delivery, segmentation, reassembly | TCP, UDP |
| internet | addressing and routing between networks | IP |
| link | transmission across the physical medium | Ethernet, Wi-Fi |
BitTorrent is the standard peer-to-peer example: a tracker coordinates peers, a swarm shares pieces of the file, and seeds hold complete copies. It spreads bandwidth cost across the peers instead of loading one server.
14.2Circuit switching and packet switching
| Circuit switching | Packet switching | |
|---|---|---|
| Path | a dedicated circuit for the whole call | packets routed independently |
| Order | data arrives in order | packets may arrive out of order and are reassembled |
| Efficiency | the circuit is wasted when idle | bandwidth is shared |
| Reliability | the whole call fails if the circuit breaks | packets are rerouted around failures |
| Suits | real-time voice | data, and most internet traffic |
A packet has a header (source and destination addresses, packet number, protocol), a payload, and a trailer (error-check bits and an end marker).
15 · Hardware and virtual machines
15.1Processors, parallel processing and virtual machines
RISC versus CISC: RISC has few, simple, fixed-length instructions executing in about one cycle, more registers, and relies on the compiler; it pipelines well and uses less power. CISC has many complex variable-length instructions, needing fewer instructions per program but more cycles each.
Pipelining overlaps the stages of the fetch–execute cycle for successive instructions, so throughput rises without the clock speed changing.
Flynn's taxonomy: SISD, SIMD, MISD, MIMD. SIMD suits applying the same operation to a large data set (graphics, arrays); MIMD is the multi-core model. Massively parallel computers link many processors for problems such as climate modelling.
A virtual machine is software emulating a computer. Uses: running an operating system inside another, running legacy software, testing safely in isolation, and consolidating servers. Limitations: slower than native execution, and it needs substantial host resources.
15.2Boolean algebra and logic circuits
| Law | Statement |
|---|---|
| identity | A·1 = A · A + 0 = A |
| null | A·0 = 0 · A + 1 = 1 |
| idempotent | A·A = A · A + A = A |
| complement | A·Ā = 0 · A + Ā = 1 |
| absorption | A + A·B = A · A·(A + B) = A |
| distributive | A·(B + C) = A·B + A·C |
Simplify Boolean expressions algebraically and with Karnaugh maps: group adjacent 1s in blocks of 1, 2, 4 or 8, in Gray-code order, wrapping around the edges, using the largest groups possible and as few as possible.
Flip-flops: the SR flip-flop stores one bit and has an invalid state when both inputs are 1; the JK flip-flop fixes this by toggling instead, and is clocked. Flip-flops are the basis of registers and of static RAM.
Simplify (Ā + B̄)‾ + A·B.
- De Morgan on the first term: (Ā + B̄)‾ = A·B.
- So the expression is A·B + A·B.
- By the idempotent law: A·B — a single AND gate replaces the whole circuit.
16 · System software (A2)
16.1Purposes of an operating system
Memory management: paging (fixed-size pages), segmentation (variable-size logical segments), and virtual memory — using disk as an extension of RAM, swapping pages in and out. Disk thrashing occurs when the system spends more time swapping pages than executing, and it is a favourite exam question.
Process management: a process moves between ready, running and blocked states. The scheduler chooses which ready process runs next, using round robin, first come first served, shortest job first or shortest remaining time. Interrupts and interrupt priorities let the OS respond to events; the low-level scheduler performs the context switch.
16.2Translation software
Stages of compilation: lexical analysis (removing comments and whitespace, producing tokens and building the symbol table), syntax analysis (parsing against the grammar, reporting syntax errors), code generation (producing object code) and optimisation (making it smaller or faster).
Backus-Naur Form (BNF) and syntax diagrams define a language's grammar formally. You should be able to read a BNF definition and decide whether a given string is valid, and to write simple BNF rules.
<letter> ::= a|b|c| … |z
<identifier> ::= <letter> | <identifier><letter> | <identifier><digit>
abc7is valid — it starts with a letter and continues with letters and digits.7abcis invalid — an identifier must begin with a letter, and there is no rule producing a leading digit.- The rule is recursive:
<identifier>appears in its own definition, which is what allows any length.
17 · Security (A2)
17.1Encryption, encryption protocols and digital certificates
Symmetric encryption uses one shared key for both encryption and decryption: fast, but the key must somehow be exchanged securely. Asymmetric encryption uses a public key to encrypt and a mathematically related private key to decrypt: it solves key distribution but is much slower. In practice, asymmetric encryption is used to exchange a symmetric session key, and the bulk of the data is then encrypted symmetrically.
Digital signatures: the sender hashes the message to produce a digest and encrypts the digest with their private key. The recipient decrypts it with the sender's public key and compares it with their own hash of the message. Matching digests prove both authenticity (only the sender's private key could have made it) and integrity (the message has not been altered).
Digital certificates are issued by a Certificate Authority and bind a public key to an identity, preventing an attacker from substituting their own public key. SSL/TLS uses certificates and an asymmetric handshake to set up an encrypted session — this is what HTTPS is.
18 · Artificial intelligence
18.1Artificial intelligence
Graph representation: AI search problems are modelled as graphs of nodes and weighted edges, stored as an adjacency matrix (fast lookup, wasteful for sparse graphs) or an adjacency list (compact for sparse graphs).
A* algorithm finds the lowest-cost path using f(n) = g(n) + h(n), where g is the cost so far and h is a heuristic estimate of the cost remaining. Dijkstra's algorithm is the special case where h = 0 — it explores in all directions, so A* is usually faster when a good heuristic exists.
Machine learning: supervised learning trains on labelled data (classification and regression); unsupervised learning finds structure in unlabelled data (clustering); reinforcement learning learns from rewards and penalties. Deep learning uses artificial neural networks with many hidden layers.
Artificial neural networks: input, hidden and output layers of nodes with weighted connections; training adjusts the weights, typically by back propagation of the error. Applications include image recognition, speech recognition, medical diagnosis and autonomous vehicles.
19 · Computational thinking and problem-solving
19.1Algorithms (A2)
Now you must write the pseudocode implementations of the abstract data types, not just describe them: push and pop on a stack, enqueue and dequeue on a queue, and insert, delete and traverse on a linked list — using an array of nodes with a free list.
Binary trees: insert a value, and traverse in pre-order (node, left, right), in-order (left, node, right — which outputs a binary search tree in sorted order) and post-order (left, right, node).
Comparing algorithms: understand time and space efficiency in broad terms — linear search is O(n), binary search O(log n), bubble and insertion sort O(n²) — and be able to justify choosing one over another for a given data set.
IF TopPointer = MaxSize THEN
OUTPUT "Stack overflow"
ELSE
TopPointer ← TopPointer + 1
Stack[TopPointer] ← Item
ENDIF
ENDPROCEDURE
The overflow (and, for pop, underflow) check is always worth a mark. Never write the bare two lines.
A binary search tree is built by inserting 50, 30, 70, 20, 40, 60, 80 in that order. Give the in-order traversal.
- 50 is the root; 30 goes left, 70 right; 20 and 40 under 30; 60 and 80 under 70.
- In-order = left, node, right → 20, 30, 40, 50, 60, 70, 80.
- Pre-order = 50, 30, 20, 40, 70, 60, 80. Post-order = 20, 40, 30, 60, 80, 70, 50.
In-order on a binary search tree always produces sorted output — a reliable check that your traversal is right.
19.2Recursion
A recursive routine calls itself. Every recursive definition needs a base case that stops the recursion and a general case that moves towards it. Recursion is implemented using a stack: each call pushes its parameters, local variables and return address, and they are popped as the calls unwind. Too deep a recursion causes stack overflow.
IF N <= 1 THEN
RETURN 1 // base case
ELSE
RETURN N * Factorial(N - 1) // general case
ENDIF
ENDFUNCTION
- Factorial(4) calls Factorial(3), which calls Factorial(2), which calls Factorial(1).
- Factorial(1) hits the base case and returns 1.
- Unwinding: 2 × 1 = 2 → 3 × 2 = 6 → 4 × 6 = 24.
- The stack held four sets of values at maximum depth.
20 · Further programming
20.1Programming paradigms
| Paradigm | Idea | Example languages |
|---|---|---|
| low-level | instructions matching the processor's own operations | assembly |
| imperative / procedural | a sequence of commands changing state | C, Pascal, Python |
| object-oriented | objects combining data and the methods that act on it | Java, C#, Python |
| declarative | state facts and rules; the system infers the answer | Prolog |
Object-oriented programming. A class is a template defining properties (attributes) and methods; an object is an instance of a class, created by a constructor. The three principles:
- Encapsulation — properties are
PRIVATEand accessed only throughPUBLICget and set methods, so an object controls its own data and cannot be put into an invalid state. - Inheritance — a subclass inherits the properties and methods of its superclass and can add its own, so common code is written once.
- Polymorphism — a subclass overrides an inherited method, so the same call produces the behaviour appropriate to the actual object.
PRIVATE Name : STRING
PUBLIC PROCEDURE NEW(GivenName : STRING)
Name ← GivenName
ENDPROCEDURE
PUBLIC FUNCTION GetName() RETURNS STRING
RETURN Name
ENDFUNCTION
PUBLIC PROCEDURE Speak()
OUTPUT "..."
ENDPROCEDURE
ENDCLASS
CLASS Dog INHERITS Animal
PUBLIC PROCEDURE Speak() // overrides — polymorphism
OUTPUT "Woof"
ENDPROCEDURE
ENDCLASS
Declarative programming in Prolog: facts such as parent(ali, sara)., rules such as grandparent(X,Z) :- parent(X,Y), parent(Y,Z)., and queries such as ?- grandparent(ali, Who). You state what is true, not how to compute it. Declarative programming is not examined in Paper 4 — only in Paper 3.
20.2File processing and exception handling
Random file access in pseudocode: OPENFILE … FOR RANDOM, SEEK to a record position, then GETRECORD or PUTRECORD. Serial and sequential files use READFILE and WRITEFILE as at AS.
SEEK "Members.dat", RecordPosition
GETRECORD "Members.dat", ThisMember
CLOSEFILE "Members.dat"
Exception handling deals with run-time errors without crashing the program — a missing file, a division by zero, a non-numeric input. The structure is try / catch (or except) / finally.
Answer ← Numerator / Denominator
EXCEPT
OUTPUT "Cannot divide by zero"
ENDTRY
Pseudocode reference
PSConventions, declarations and constructs
Conventions: keywords in CAPITALS, identifiers in MixedCase, assignment with ←, comments after //, and consistent indentation for every block.
DECLARE Counter : INTEGER
CONSTANT Pi = 3.14159
DECLARE Marks : ARRAY[1:30] OF INTEGER
DECLARE Grid : ARRAY[1:5, 1:8] OF CHAR
TYPE Student
DECLARE Name : STRING
DECLARE Age : INTEGER
ENDTYPE
INPUT Name
OUTPUT "Hello ", Name
IF Score >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
CASE OF Grade
"A" : OUTPUT "Excellent"
"B" : OUTPUT "Good"
OTHERWISE : OUTPUT "See teacher"
ENDCASE
FOR Index ← 1 TO 10
OUTPUT Index
NEXT Index
WHILE Total < 100 DO
Total ← Total + 5
ENDWHILE
REPEAT
INPUT Password
UNTIL Password = "open"
PROCEDURE ShowTotal(BYVALUE Amount : INTEGER)
OUTPUT "Total is ", Amount
ENDPROCEDURE
CALL ShowTotal(50)
FUNCTION Square(N : INTEGER) RETURNS INTEGER
RETURN N * N
ENDFUNCTION
Result ← Square(7)
OPENFILE "Data.txt" FOR READ // or WRITE, APPEND, RANDOM
READFILE "Data.txt", LineOfText
WRITEFILE "Data.txt", LineOfText
IF EOF("Data.txt") THEN … ENDIF
CLOSEFILE "Data.txt"
arithmetic: + - * / DIV MOD ^
relational: = <> < <= > >=
logical: AND OR NOT
strings: LENGTH(S) · LEFT(S, n) · RIGHT(S, n) · MID(S, start, n) · LCASE(c) · UCASE(c)
numeric: INT(x) · RAND(n)
conversion: NUM_TO_STR(x) · STR_TO_NUM(s)
ENDIF, NEXT, ENDWHILE, ENDPROCEDURE), and declaring variables without a type. Both are free marks once the habit is fixed.Number bases and conversions
NBThe conversions you must be able to do on paper
Place values to memorise: 128 · 64 · 32 · 16 · 8 · 4 · 2 · 1 for a byte, and 4096 · 256 · 16 · 1 for four hexadecimal digits.
| Denary | Binary | Hex | BCD |
|---|---|---|---|
| 0 | 0000 | 0 | 0000 |
| 5 | 0101 | 5 | 0101 |
| 9 | 1001 | 9 | 1001 |
| 10 | 1010 | A | 0001 0000 |
| 12 | 1100 | C | 0001 0010 |
| 15 | 1111 | F | 0001 0101 |
| 16 | 0001 0000 | 10 | 0001 0110 |
| 255 | 1111 1111 | FF | 0010 0101 0101 |
Convert 201.
- 128 fits → 1, remainder 73. 64 fits → 1, remainder 9. 32 → 0. 16 → 0.
- 8 fits → 1, remainder 1. 4 → 0. 2 → 0. 1 fits → 1.
- 1100 1001. Check: 128 + 64 + 8 + 1 = 201 ✓
Convert 1100 1001 to hex, and 2F to binary and denary.
- 1100 = 12 = C · 1001 = 9 → C9.
- 2 = 0010, F = 1111 → 0010 1111.
- Denary: 2 × 16 + 15 = 47.
Add 0110 1101 and 0101 0011 in 8 bits.
- 109 + 83 = 192.
- Binary result: 1100 0000 = 192 ✓ — fits in 8 bits as an unsigned value.
- But interpreted as signed two's complement, 1100 0000 is −64: two positive numbers have produced a negative result, which is an overflow.
Overflow in two's complement is detected exactly this way: adding two positives gives a negative, or adding two negatives gives a positive.
Paper 4: the practical exam
P4What to expect and how to prepare
2 hours 30 minutes, 75 marks, sat on a computer with no internet or email. It assesses sections 19 and 20 — except low-level and declarative programming, so no assembly and no Prolog. You submit complete program code and evidence of testing, and you work in Java, VB.NET or Python, all in console mode.
What you will be asked to implement, in your chosen language:
- Classes with private attributes, constructors, get and set methods, inheritance and overridden methods.
- Stacks, queues, linked lists and binary trees, with their operations.
- Recursive routines.
- Reading from and writing to text files, and random access to record files.
- Exception handling around file access, division and type conversion.
- Validation of input, with sensible messages.
Evidence of testing means screenshots or captured console output showing the program running with the data specified in the question. Marks are lost every session for code that works but has no evidence attached.
Definitions bank
LearnThe definitions examiners want verbatim
| Term | Definition |
|---|---|
| Abstraction | The process of removing unnecessary detail from a problem so that only the relevant features remain. |
| Decomposition | Breaking a problem down into smaller sub-problems that can be solved separately. |
| Algorithm | A finite sequence of unambiguous steps that solves a problem. |
| Two's complement | A method of representing signed integers in which a negative value is formed by inverting all the bits of the positive value and adding one. |
| Normalisation (floating point) | Adjusting the mantissa and exponent so that the mantissa begins 0.1 for a positive number or 1.0 for a negative one, giving maximum precision. |
| Lossless compression | Compression from which the original file can be reconstructed exactly. |
| Lossy compression | Compression in which some data is permanently discarded to reduce file size. |
| Protocol | A set of rules governing the transmission of data between devices. |
| Interrupt | A signal sent to the processor that causes it to suspend the current program and run an interrupt service routine. |
| Fetch–execute cycle | The repeated process by which the processor fetches, decodes and executes each instruction. |
| Pipelining | Overlapping the stages of the fetch–execute cycle for successive instructions to increase throughput. |
| Virtual memory | The use of secondary storage as an extension of main memory, with pages swapped in and out as needed. |
| Disk thrashing | A state in which the system spends more time swapping pages than executing instructions. |
| Compiler | A program that translates a complete high-level program into machine code before execution. |
| Interpreter | A program that translates and executes a high-level program one statement at a time. |
| Validation | An automatic check that data entered is reasonable and within acceptable limits. |
| Verification | A check that data has been accurately copied or transferred without change. |
| Primary key | A field, or combination of fields, that uniquely identifies each record in a table. |
| Foreign key | A field in one table that refers to the primary key of another table. |
| Referential integrity | The rule that every foreign key value must match an existing primary key value, or be null. |
| Normalisation (databases) | The process of organising data into tables to remove redundancy and dependency problems. |
| Stack | A last-in first-out data structure with push and pop operations. |
| Queue | A first-in first-out data structure with enqueue and dequeue operations. |
| Recursion | A routine that calls itself, having a base case that ends the recursion and a general case that moves towards it. |
| Class | A template that defines the properties and methods of a type of object. |
| Object | An instance of a class, created by its constructor. |
| Encapsulation | Keeping an object's data private and accessible only through its own public methods. |
| Inheritance | A subclass acquiring the properties and methods of its superclass. |
| Polymorphism | The ability of a subclass to override an inherited method so that the same call behaves differently. |
| Symmetric encryption | Encryption in which the same key is used to encrypt and to decrypt. |
| Asymmetric encryption | Encryption using a public key to encrypt and a related private key to decrypt. |
| Digital signature | A message digest encrypted with the sender's private key, proving authenticity and integrity. |
| Digital certificate | A document issued by a Certificate Authority that binds a public key to the identity of its owner. |
| Supervised learning | Machine learning in which the model is trained on labelled data. |
| Unsupervised learning | Machine learning in which the model finds patterns in unlabelled data. |
Study planner & progress
Every syllabus unit. Tick one when you can answer a past-paper question on it unaided. Your ticks are saved on this device only — nothing is sent anywhere, and there is no account to create.
Loading…
Free past papers & how to revise
Official (free)
- Cambridge International — 9618 subject page: syllabus, specimen papers, past papers, mark schemes and examiner reports.
- Examiner reports name the exact questions candidates got wrong each series — read them for every paper you attempt.
Free archives
- GCE Guide · PastPapers.co — full CAIE past-paper archives.
- Physics & Maths Tutor — topic-sorted questions.
How to revise this subject
- Write pseudocode by hand, every week. Paper 2 is answered entirely in pseudocode, and the only way to get fast at it is to write it — not read it.
- Learn the official pseudocode conventions. Cambridge publishes a Pseudocode Guide; the reference section below covers the constructs you need. Arrays are declared with explicit bounds, assignment uses ←, and keywords are in capitals.
- Trace tables win marks. When asked to dry-run an algorithm, draw the table, one column per variable, one row per iteration. Show every change.
- Do the number conversions on paper. No calculator means you need the doubling method, the 16s-and-1s method for hex, and two's complement by "invert and add one".
- Pick your Paper 4 language early and stick to it. Java, VB.NET or Python. Learn its file handling, exception handling and OOP syntax cold — not three languages badly.
- Answer theory questions with the technical term. "Interrupt", "cache", "pipelining", "normalisation", "referential integrity", "encapsulation" — the term is usually the mark.