9618 Paper 3 โ Advanced Theory
13Data Representation
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.
| Binary | Decimal | Hex |
|---|---|---|
| 0000 | 0 | 0 |
| 1010 | 10 | A |
| 1111 | 15 | F |
| 11111111 | 255 | FF |
Two's complement (signed integers)
For 8-bit two's complement, the MSB has value โ128. So 10000000 = โ128, 11111111 = โ1, 01111111 = +127.
To negate a number:
- Invert all bits (one's complement)
- Add 1
Worked example
+5 in 8-bit:00000101 โ invert: 11111010 โ add 1: 11111011 = โ5Binary 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
| ASCII | Unicode |
|---|---|
| 7 bits (128 chars) | 16+ bits (millions of chars) |
| English alphabet only | All world scripts |
| Small files | Larger files |
14User-Defined Data Types
Non-composite types (enumerated, pointer)
Example:
TYPE TDayOfWeek = (Mon, Tue, Wed, Thu, Fri, Sat, Sun)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
| Type | Use when |
|---|---|
| Enumerated | Fixed list of named options (months, suits) |
| Pointer | Building linked lists, trees, dynamic structures |
| Record | Grouping mixed fields about one thing |
| Set | Unique items, mathematical set operations |
15File Organisation & Access
File organisation methods
| Method | Order | Best for |
|---|---|---|
| Serial | Order of arrival | Logs, transaction files |
| Sequential | Sorted by key | Payroll, batch processing |
| Index-sequential | Sorted + index | Fast lookups + range queries |
| Random (direct) | By hash address | Fast direct lookups |
Hashing
address = key MOD table_sizeCollisions
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.
16Floating-Point Numbers
Form
A floating-point number = mantissa ร 2exponent. Both stored in two's complement.
Normalisation
Why normalise?
- Unique representation for each value
- Maximum precision in the available bits
- Easier comparison
Errors
| Error | Cause |
|---|---|
| Overflow | Number too large for the exponent |
| Underflow | Number too small (very close to 0) |
| Rounding error | Mantissa truncated |
| Loss of precision | Subtracting very similar numbers |
17Communication & Networking
TCP/IP protocol stack (4 layers)
| Layer | Role | Examples |
|---|---|---|
| Application | User-facing protocols | HTTP, FTP, SMTP, DNS |
| Transport | End-to-end delivery, reliability | TCP, UDP |
| Internet | Routing, IP addressing | IP, ICMP |
| Link (Network access) | Physical transmission | Ethernet, 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
RISC vs CISC
| RISC | CISC |
|---|---|
| Few simple instructions | Many complex instructions |
| Each instruction one cycle | Variable cycles |
| Fixed-length instructions | Variable-length |
| Hardwired control | Microcoded |
| Lower power, mobile devices | Desktops, 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.
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
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
Handling: save state on stack โ run ISR (interrupt service routine) โ restore state โ resume. Sources: I/O, timer, hardware error, software exception.
Scheduling
| Algorithm | Idea |
|---|---|
| FCFS | First-come, first-served |
| SJF | Shortest job first |
| Round robin | Each gets a time slice (quantum) |
| Multilevel feedback | Multiple queues, dynamic priority |
Translation: compiler vs interpreter vs assembler
| Compiler | Interpreter | Assembler | |
|---|---|---|---|
| Input | High-level source | High-level source | Assembly |
| Output | Object code | Runs line-by-line | Machine code |
| Speed | Fast at runtime | Slow at runtime | Fast |
| Debug | Harder | Easier | Hard |
Compilation phases
- Lexical analysis โ break source into tokens; build symbol table
- Syntax analysis โ check tokens fit grammar; build parse tree
- Semantic analysis โ check meaning (types, declarations)
- Code generation โ produce object code
- Optimisation โ improve efficiency
20Security, Privacy & Data Integrity
Symmetric vs asymmetric encryption
| Symmetric | Asymmetric |
|---|---|
| Same key for encrypt/decrypt | Public key + private key |
| Fast | Slower |
| Key distribution problem | No shared secret needed |
| AES, DES | RSA |
Digital signatures
- Sender hashes message โ message digest
- Encrypts digest with their private key โ signature
- Receiver decrypts with sender's public key โ expected digest
- Receiver hashes message themselves and compares
SSL / TLS handshake
- Client sends "ClientHello" + supported ciphers
- Server responds with certificate + chosen cipher
- Client verifies certificate via Certificate Authority
- Both agree a symmetric session key (using asymmetric encryption)
- 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
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
| Type | Data | Example |
|---|---|---|
| Supervised | Labelled inputs/outputs | Spam detection, image classification |
| Unsupervised | Unlabelled โ find clusters | Customer segmentation |
| Reinforcement | Rewards from environment | Game-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
Boolean laws
| Law | Form |
|---|---|
| Identity | Aยท1 = A, A+0 = A |
| Null | Aยท0 = 0, A+1 = 1 |
| Idempotent | AยทA = A, A+A = A |
| Complement | AยทAฬ = 0, A+Aฬ = 1 |
| De Morgan 1 | (AยทB)ฬ = Aฬ + Bฬ |
| De Morgan 2 | (A+B)ฬ = Aฬ ยท Bฬ |
| Distributive | Aยท(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.
23BNF & RPN
Backus-Naur Form (BNF)
| 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.
| Infix | RPN |
|---|---|
| 3 + 4 | 3 4 + |
| (3 + 4) ร 5 | 3 4 + 5 ร |
| 3 + 4 ร 5 | 3 4 5 ร + |
Evaluating RPN with a stack
- Read left to right
- If number โ push onto stack
- If operator โ pop top two, apply, push result
- 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