9618 CompSci Hub
โ— Ready

9618 Paper 3 โ€” Advanced Theory

Cambridge International A Level Computer Science 9618 (2026 Syllabus)
Paper 3 ยท 1h 30m ยท 75 marks Sections 13โ€“23 (theory)

13Data Representation

Numbers, characters, images, and sound โ€” how a computer stores them.

Number bases

Computers use binary (base 2). Humans often use hexadecimal (base 16) as a compact way to write binary because 4 binary digits = 1 hex digit.

BinaryDecimalHex
000000
101010A
111115F
11111111255FF

Two's complement (signed integers)

Two's complement: the standard way to represent negative integers. The most significant bit has a negative place value; everything else is positive.

For 8-bit two's complement, the MSB has value โˆ’128. So 10000000 = โˆ’128, 11111111 = โˆ’1, 01111111 = +127.

To negate a number:

  1. Invert all bits (one's complement)
  2. Add 1
Worked example
+5 in 8-bit: 00000101 โ†’ invert: 11111010 โ†’ add 1: 11111011 = โˆ’5

Binary Coded Decimal (BCD)

Each decimal digit (0โ€“9) is encoded as 4 bits. Used in calculators and electronic displays where precise decimal arithmetic matters.

ASCII vs Unicode

ASCIIUnicode
7 bits (128 chars)16+ bits (millions of chars)
English alphabet onlyAll world scripts
Small filesLarger files

14User-Defined Data Types

Building your own types: composite, non-composite, classes, pointers.

Non-composite types (enumerated, pointer)

Enumerated type: a user-defined list of named values with implicit ordering.
Example: TYPE TDayOfWeek = (Mon, Tue, Wed, Thu, Fri, Sat, Sun)
Pointer type: stores a memory address. TYPE TIntPtr = ^INTEGER declares a pointer to an integer.

Composite types (record, set, class)

Record

TYPE TStudent
   DECLARE Name : STRING
   DECLARE Age  : INTEGER
   DECLARE Mark : REAL
ENDTYPE

Records group different data types under one name. Each field has its own type. Access using dot notation: student.Name.

Set

A collection of unique values of the same type with set operations like union (โˆช), intersection (โˆฉ), difference (โˆ’).

Class

A blueprint for objects (covered in Topic 20.1 โ€” OOP).

When to use each

TypeUse when
EnumeratedFixed list of named options (months, suits)
PointerBuilding linked lists, trees, dynamic structures
RecordGrouping mixed fields about one thing
SetUnique items, mathematical set operations

15File Organisation & Access

Serial, sequential, random, index-sequential โ€” and hashing.

File organisation methods

MethodOrderBest for
SerialOrder of arrivalLogs, transaction files
SequentialSorted by keyPayroll, batch processing
Index-sequentialSorted + indexFast lookups + range queries
Random (direct)By hash addressFast direct lookups

Hashing

Hashing algorithm: a function that converts a key into a storage address. Example: address = key MOD table_size

Collisions

When two keys hash to the same address. Resolution methods:

  • Linear probing โ€” try next slot, then next, until empty.
  • Chaining โ€” store a linked list at each address.
  • Rehashing โ€” apply a second hash function.
A poor hash function creates many collisions and degrades to O(n) performance. Use a function that distributes keys evenly.

16Floating-Point Numbers

How real numbers are stored โ€” mantissa, exponent, normalisation.

Form

A floating-point number = mantissa ร— 2exponent. Both stored in two's complement.

Example layout (8-bit mantissa, 4-bit exponent)M = 0.5 ร— 23 = 4

Normalisation

Normalised form: the mantissa's first two bits are different (01โ€ฆ for positive, 10โ€ฆ for negative). This gives maximum precision.

Why normalise?

  • Unique representation for each value
  • Maximum precision in the available bits
  • Easier comparison

Errors

ErrorCause
OverflowNumber too large for the exponent
UnderflowNumber too small (very close to 0)
Rounding errorMantissa truncated
Loss of precisionSubtracting very similar numbers

17Communication & Networking

Protocols, TCP/IP, packet switching, circuit switching.

TCP/IP protocol stack (4 layers)

LayerRoleExamples
ApplicationUser-facing protocolsHTTP, FTP, SMTP, DNS
TransportEnd-to-end delivery, reliabilityTCP, UDP
InternetRouting, IP addressingIP, ICMP
Link (Network access)Physical transmissionEthernet, Wi-Fi

Packet switching

  • Data broken into small packets with headers
  • Each packet routed independently through the network
  • Reassembled at the destination
  • Resilient โ€” failed links cause re-routing, not failure

Circuit switching

Dedicated end-to-end path for the whole call (old telephone networks). Wastes bandwidth when idle, but no congestion once connected.

BitTorrent (peer-to-peer)

Files split into pieces shared between many peers. A tracker manages who has which piece. Reduces server load and is resilient.

18Hardware

CISC vs RISC, pipelining, parallel processing, virtual machines.

RISC vs CISC

RISCCISC
Few simple instructionsMany complex instructions
Each instruction one cycleVariable cycles
Fixed-length instructionsVariable-length
Hardwired controlMicrocoded
Lower power, mobile devicesDesktops, x86

Pipelining

The processor fetches the next instruction while still executing the current one โ€” like an assembly line. Stages typically: Fetch โ†’ Decode โ†’ Execute โ†’ Memory โ†’ Write-back.

Pipelining increases throughput, not the speed of any single instruction. A branch can stall (flush) the pipeline.

Parallel processing

  • SISD โ€” single instruction, single data (classical)
  • SIMD โ€” same instruction on many data items (graphics, vectors)
  • MIMD โ€” different instructions on different data (modern multi-core)
  • Massively parallel โ€” supercomputers, weather simulation

Virtual machines

Software that emulates a computer. Benefits: run multiple OSes on one host, isolated sandboxes, server consolidation. Drawbacks: slower than native, needs more RAM, single point of failure.

19System Software

OS functions, memory management, interrupts, scheduling, translation.

Operating system functions

  • Memory management
  • File management
  • Input/output management
  • Process / CPU scheduling
  • Security / access control
  • Provide user interface
  • Interrupt handling

Memory management

Paging

Physical memory divided into fixed page frames; programs divided into matching pages. A page table maps logical โ†’ physical pages.

Segmentation

Memory divided into variable-size segments matching logical units (code, stack, data). May cause external fragmentation.

Virtual memory

Uses disk as if it were RAM. Page fault = required page not in RAM โ†’ swap in from disk. Thrashing = excessive paging that slows the whole system.

Interrupts

Interrupt: a signal that pauses normal CPU execution so a higher-priority task can be handled.

Handling: save state on stack โ†’ run ISR (interrupt service routine) โ†’ restore state โ†’ resume. Sources: I/O, timer, hardware error, software exception.

Scheduling

AlgorithmIdea
FCFSFirst-come, first-served
SJFShortest job first
Round robinEach gets a time slice (quantum)
Multilevel feedbackMultiple queues, dynamic priority

Translation: compiler vs interpreter vs assembler

CompilerInterpreterAssembler
InputHigh-level sourceHigh-level sourceAssembly
OutputObject codeRuns line-by-lineMachine code
SpeedFast at runtimeSlow at runtimeFast
DebugHarderEasierHard

Compilation phases

  1. Lexical analysis โ€” break source into tokens; build symbol table
  2. Syntax analysis โ€” check tokens fit grammar; build parse tree
  3. Semantic analysis โ€” check meaning (types, declarations)
  4. Code generation โ€” produce object code
  5. Optimisation โ€” improve efficiency

20Security, Privacy & Data Integrity

Encryption, hashing, digital certificates, SSL/TLS, DRM.

Symmetric vs asymmetric encryption

SymmetricAsymmetric
Same key for encrypt/decryptPublic key + private key
FastSlower
Key distribution problemNo shared secret needed
AES, DESRSA

Digital signatures

  1. Sender hashes message โ†’ message digest
  2. Encrypts digest with their private key โ†’ signature
  3. Receiver decrypts with sender's public key โ†’ expected digest
  4. Receiver hashes message themselves and compares

SSL / TLS handshake

  1. Client sends "ClientHello" + supported ciphers
  2. Server responds with certificate + chosen cipher
  3. Client verifies certificate via Certificate Authority
  4. Both agree a symmetric session key (using asymmetric encryption)
  5. Rest of session uses fast symmetric encryption

Digital certificates

A document signed by a trusted Certificate Authority binding a public key to an identity. Contains: name, public key, validity period, CA's signature.

21Artificial Intelligence

Machine learning, neural networks, deep learning.

Categories

  • Narrow AI โ€” does one task well (chess, image recognition)
  • General AI โ€” human-level across tasks (research goal)
  • Strong AI โ€” exceeds human capability

Machine learning types

TypeDataExample
SupervisedLabelled inputs/outputsSpam detection, image classification
UnsupervisedUnlabelled โ€” find clustersCustomer segmentation
ReinforcementRewards from environmentGame-playing agents

Neural network

Layers of nodes (neurons). Each connection has a weight. Input ร— weight summed โ†’ activation function โ†’ output. Training adjusts weights to minimise error using back-propagation.

  • Input layer โ€” receives raw data
  • Hidden layers โ€” extract features
  • Output layer โ€” produces prediction

Deep learning = neural network with many hidden layers.

22Boolean Algebra & Logic Circuits

Truth tables, K-maps, flip-flops, half/full adders.

Boolean laws

LawForm
IdentityAยท1 = A, A+0 = A
NullAยท0 = 0, A+1 = 1
IdempotentAยทA = A, A+A = A
ComplementAยทAฬ… = 0, A+Aฬ… = 1
De Morgan 1(AยทB)ฬ… = Aฬ… + Bฬ…
De Morgan 2(A+B)ฬ… = Aฬ… ยท Bฬ…
DistributiveAยท(B+C) = AยทB + AยทC

Karnaugh maps (K-maps)

A grid arrangement of a truth table where adjacent cells differ by one variable (Gray code order). Group 1s in rectangles of size 1, 2, 4, 8โ€ฆ to simplify Boolean expressions.

Half adder

Two inputs (A, B), two outputs: Sum = AโŠ•B, Carry = AยทB.

Full adder

Three inputs (A, B, Cin), two outputs: Sum = AโŠ•BโŠ•Cin, Cout = (AยทB) + (Cinยท(AโŠ•B)).

Flip-flops

SR flip-flop

S=1, R=0 โ†’ Q=1 (set). S=0, R=1 โ†’ Q=0 (reset). S=R=0 โ†’ hold. S=R=1 โ†’ invalid.

JK flip-flop

Fixes SR's invalid state. J=K=1 โ†’ Q toggles. Clock-triggered.

Flip-flops are 1-bit memory cells โ€” combine many to build registers.

23BNF & RPN

Defining language grammars and evaluating expressions.

Backus-Naur Form (BNF)

BNF: a notation for defining context-free grammars. Uses ::= for "is defined as" and | for alternatives. Terminals are literal characters; non-terminals are wrapped in < >.
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<integer> ::= <digit> | <digit><integer>

The recursion in <integer> lets it match strings of any length.

Reverse Polish Notation (RPN)

Operators come after their operands. No brackets needed.

InfixRPN
3 + 43 4 +
(3 + 4) ร— 53 4 + 5 ร—
3 + 4 ร— 53 4 5 ร— +

Evaluating RPN with a stack

  1. Read left to right
  2. If number โ†’ push onto stack
  3. If operator โ†’ pop top two, apply, push result
  4. Final stack value = answer
Example: 3 4 + 5 ร—
Push 3 โ†’ [3]
Push 4 โ†’ [3,4]
+ โ†’ pop 4 and 3, push 7 โ†’ [7]
Push 5 โ†’ [7,5]
ร— โ†’ pop 5 and 7, push 35 โ†’ [35]
Answer: 35

9618 Paper 4 โ€” Practical Programming (Python)

Cambridge A Level Computer Science ยท Sections 19 + 20
Paper 4 ยท 2h 30m ยท 75 marks ยท 100% AO3 Computer-based, no internet

19.1aAlgorithms โ€” Searching

Linear search and binary search.

Linear search

Check each item until found โ€” works on any list, sorted or not.

def linear_search(arr, target):
    for i in range(len(arr)):
        if arr[i] == target:
            return i
    return -1

Complexity: O(n) worst case.

Binary search

Halve the search range each step. Requires sorted data.

def binary_search(arr, target):
    low, high = 0, len(arr) - 1
    while low <= high:
        mid = (low + high) // 2
        if arr[mid] == target:
            return mid
        elif arr[mid] < target:
            low = mid + 1
        else:
            high = mid - 1
    return -1

Complexity: O(log n).

If the array is not sorted, binary search gives wrong answers. State this requirement explicitly in exams.

19.1bAlgorithms โ€” Sorting

Bubble sort and insertion sort.

Bubble sort

Repeatedly compare adjacent items and swap if out of order. After each pass the largest unsorted element "bubbles" to the end.

def bubble_sort(arr):
    n = len(arr)
    for i in range(n - 1):
        for j in range(n - 1 - i):
            if arr[j] > arr[j+1]:
                arr[j], arr[j+1] = arr[j+1], arr[j]
    return arr

Complexity: O(nยฒ) worst, O(n) best (with early-exit flag).

Insertion sort

Build a sorted list one element at a time by inserting each new element in the right place.

def insertion_sort(arr):
    for i in range(1, len(arr)):
        key = arr[i]
        j = i - 1
        while j >= 0 and arr[j] > key:
            arr[j+1] = arr[j]
            j -= 1
        arr[j+1] = key
    return arr

Complexity: O(nยฒ) worst, O(n) best. Often faster than bubble in practice.

19.1cADTs โ€” Stack & Queue

LIFO and FIFO collections.

Stack (LIFO)

Operations: push, pop, peek, isEmpty.

class Stack:
    def __init__(self):
        self.__items = []
    def push(self, x): self.__items.append(x)
    def pop(self):
        if self.is_empty(): raise Exception("Stack underflow")
        return self.__items.pop()
    def peek(self): return self.__items[-1]
    def is_empty(self): return len(self.__items) == 0

Uses: function call stack, undo, expression evaluation, RPN.

Queue (FIFO)

class Queue:
    def __init__(self):
        self.__items = []
    def enqueue(self, x): self.__items.append(x)
    def dequeue(self):
        if self.is_empty(): raise Exception("Queue underflow")
        return self.__items.pop(0)
    def is_empty(self): return len(self.__items) == 0

Uses: print queue, breadth-first search, task scheduling, message buffers.

19.1dADTs โ€” Linked List & Binary Tree

Pointer-based dynamic structures.

Linked list

A chain of nodes. Each node holds data and a pointer to the next node. The head points to the first node; the last node points to None.

class Node:
    def __init__(self, data):
        self.data = data
        self.next = None

class LinkedList:
    def __init__(self):
        self.head = None
    def insert(self, data):
        n = Node(data); n.next = self.head; self.head = n
    def find(self, target):
        cur = self.head
        while cur:
            if cur.data == target: return True
            cur = cur.next
        return False

Binary search tree (BST)

Each node has up to two children. Rule: left child < parent < right child. In-order traversal visits values in sorted order.

class TreeNode:
    def __init__(self, data):
        self.data = data
        self.left = None
        self.right = None

19.1eDictionary & Graph

Dictionary

Key โ†’ value pairs. Average O(1) lookup. In Python use {}.

contacts = {"Alice": "1234", "Bob": "5678"}
print(contacts["Alice"])

Graph (knowledge only โ€” no code required)

A set of nodes (vertices) connected by edges. Edges can be directed/undirected and weighted/unweighted.

Uses: social networks, maps, computer networks, dependency graphs.

Implemented as an adjacency list (dictionary of neighbours) or adjacency matrix (2D array).

19.1fBig O Complexity

AlgorithmBestAverageWorst
Linear searchO(1)O(n)O(n)
Binary searchO(1)O(log n)O(log n)
Bubble sortO(n)O(nยฒ)O(nยฒ)
Insertion sortO(n)O(nยฒ)O(nยฒ)

Space complexity

How much extra memory the algorithm uses. Bubble sort = O(1) extra (in-place). Merge sort = O(n) extra.

19.2Recursion

A function that calls itself.

Essential features

  1. Base case โ€” when to stop
  2. Recursive call โ€” heading toward the base case
  3. Unwinding โ€” calls return back up the chain
def factorial(n):
    if n == 0:                  # base case
        return 1
    return n * factorial(n - 1) # recursive call

Stack frames

Each recursive call adds a new stack frame holding local variables and return address. Too many frames โ†’ stack overflow.

When recursion beats iteration

  • Tree / graph traversal
  • Divide-and-conquer (mergesort, quicksort)
  • Problems with naturally recursive definitions (factorial, Fibonacci, Towers of Hanoi)
Recursion uses more memory than iteration. Always identify the base case explicitly in comments.

20.1aOOP โ€” Classes & Objects

Key terms

TermMeaning
ClassBlueprint / template
Object (instance)Actual thing built from class
Attribute (property)Data stored in object
MethodFunction in a class
Constructor__init__ โ€” runs at object creation
class Student:
    def __init__(self, name, year):
        self.name = name
        self.year = year
    def greet(self):
        print(f"Hi, I'm {self.name}")

20.1bOOP โ€” Encapsulation & Inheritance

Encapsulation

Hide internal data using __ prefix (private). Provide controlled access via getters and setters (with validation).

class Account:
    def __init__(self, balance):
        self.__balance = balance
    def get_balance(self):
        return self.__balance
    def deposit(self, x):
        if x <= 0: raise Exception("Invalid")
        self.__balance += x

Inheritance ("is-a")

Child class reuses + extends parent.

class Animal:
    def __init__(self, name): self.name = name
    def speak(self): print("sound")

class Dog(Animal):
    def speak(self): print(f"{self.name} says Woof!")

20.1cOOP โ€” Polymorphism & Containment

Polymorphism ("many forms")

Same method name behaves differently on different classes. Achieved by method overriding.

Containment ("has-a") / Aggregation

An object holds another object as an attribute.

class Engine:
    def __init__(self, hp): self.hp = hp

class Car:
    def __init__(self, model, hp):
        self.model = model
        self.engine = Engine(hp)   # car HAS-A engine
Inheritance = "is-a" (Dog IS-A Animal). Containment = "has-a" (Car HAS-A Engine). Memorise the distinction for long-answer questions.

20.2File & Exception Handling

File modes

ModeMeaning
"r"Read (must exist)
"w"Write (creates/overwrites)
"a"Append (creates if needed)

File access types

  • Serial โ€” records in order of arrival
  • Sequential โ€” sorted by key, read in order
  • Random โ€” direct access by record number / hash

Reading and writing

with open("data.txt", "w") as f:
    f.write("Alice\n")
    f.write("Bob\n")

with open("data.txt", "r") as f:
    for line in f:
        print(line.strip())

Exception handling

try:
    x = int(input())
    print(100 / x)
except ValueError:
    print("Not a number")
except ZeroDivisionError:
    print("Can't divide by zero")
finally:
    print("Always runs")

Raise your own: raise Exception("message").

โ˜…Exam Strategy

Evidence document required

  • Full code listings (copy-paste from IDE)
  • Screenshots of program running each test case
  • Contents of any data files used

Test data โ€” three types

TypeExample (age 0-120)
Normal25
Boundary0, 120
Erroneous-1, 121, "abc"

Marks awarded for

  • Correctness of code
  • Meaningful identifier names
  • Comments and structure
  • Test evidence (screenshots)
  • Appropriate use of constructs (loops, functions, OOP)

Common pitfalls

  • Forgetting int(input()) for numeric input
  • Not using with open (file might not close)
  • No try/except around risky operations
  • Missing base case in recursion
  • Off-by-one errors in loops

9618 Computer Science AI Tutor