ALU — Arithmetic Logic Unit
Performs all arithmetic (add, subtract, multiply) and logical (AND, OR, NOT, comparisons) operations. The computational engine of the CPU.
Control Unit (CU)
Coordinates all CPU activity. Fetches instructions, decodes them, and controls the flow of data between CPU components and memory. Does NOT process data itself.
Registers
| Register | Full Name | Role |
|---|---|---|
| PC | Program Counter | Holds the address of the NEXT instruction to fetch |
| MAR | Memory Address Register | Holds the address in memory being read from/written to |
| MDR | Memory Data Register | Temporarily holds data read from or to be written to memory |
| CIR | Current Instruction Register | Holds the instruction currently being decoded/executed |
| ACC | Accumulator | Stores results of ALU calculations |
Buses
- Carries data between CPU, memory and I/O
- Bidirectional
- Width = word size (e.g. 64-bit)
- Carries memory addresses
- Unidirectional (CPU → memory)
- Width determines addressable memory
- Carries control signals (read, write, clock, interrupt)
- Bidirectional
- Coordinates operations
FETCH
Contents of PC copied to MAR via address bus
Memory at address in MAR is read; data copied to MDR via data bus
Instruction copied from MDR to CIR
PC is incremented (points to next instruction)
DECODE
Control unit decodes the instruction in the CIR
Splits into opcode (what to do) and operand (what to do it to)
EXECUTE
Appropriate components activated (ALU, registers, memory)
Instruction carried out; result may go to ACC or memory
CPU Performance Factors
| Factor | Effect |
|---|---|
| Clock speed | Higher = more FDE cycles per second (measured in GHz). More heat generated. |
| Number of cores | More cores = more instructions in parallel. Limited by software that can utilise them. |
| Cache size | Larger cache = more data stored close to CPU, fewer slow RAM accesses. L1 fastest, L3 largest. |
Pipelining
While one instruction is being executed, the next is being decoded and the one after is being fetched. Overlapping stages increases throughput.
Von Neumann Architecture
- Single memory stores both data and instructions
- Single shared bus — can only do one at a time (bottleneck)
- Used by most general-purpose computers
- The "Von Neumann bottleneck" = slow memory access limits CPU speed
Harvard Architecture
- Separate memory and buses for data and instructions
- Data and instructions fetched simultaneously — no bottleneck
- More complex and expensive
- Used in: embedded systems, DSPs, microcontrollers
OCR uses LMC as a simplified model of assembly language. You must be able to follow and write programs.
| Mnemonic | Meaning |
|---|---|
| INP | Input a value → ACC |
| OUT | Output ACC value |
| LDA xx | Load value from address xx into ACC |
| STA xx | Store ACC value to address xx |
| ADD xx | Add value at address xx to ACC |
| SUB xx | Subtract value at address xx from ACC |
| BRP xx | Branch to xx if ACC ≥ 0 |
| BRZ xx | Branch to xx if ACC = 0 |
| BRA xx | Always branch to xx |
| HLT | Stop program |
| DAT | Declare a memory location |
Example: Add two numbers
INP // get first number → ACC STA NUM1 // store in NUM1 INP // get second number → ACC ADD NUM1 // ACC = ACC + NUM1 OUT // output result HLT NUM1 DAT // memory location
Addressing Modes
- Immediate — operand is the actual value (e.g. LDA #5, loads 5)
- Direct — operand is the memory address containing the value
- Indirect — operand is address that holds the address of the value
- Indexed — address = operand + index register value
RISC — Reduced Instruction Set Computer
- Small instruction set — each instruction is simple
- Each instruction takes one clock cycle
- Instructions are single lines of machine code
- Pipelining is easy and efficient
- Compiler must do more work to break down complex tasks
- Needs more RAM (longer programs)
- Used in: smartphones (ARM), tablets, embedded systems
// RISC: multiply X by Y LDA R1, X LDA R2, Y MULT R1, R2 STO R1, X
CISC — Complex Instruction Set Computer
- Large instruction set — complex multi-step instructions
- Instructions can take multiple clock cycles
- Instructions built into hardware (microcode)
- Pipelining harder (variable instruction length)
- Compiler has less work — one instruction does more
- Needs less RAM (shorter programs)
- Used in: desktops, laptops (x86 Intel/AMD)
// CISC: same multiply in one instruction MULT A, B
| RISC | CISC | |
|---|---|---|
| Instruction set | Small, simple | Large, complex |
| Clock cycles per instruction | 1 | Multiple |
| Pipelining | Easy | Hard |
| Compiler complexity | High | Low |
| RAM required | More | Less |
| Examples | ARM (phones) | x86 (PCs) |
GPU — Graphics Processing Unit
- Contains thousands of small cores optimised for parallel tasks
- A co-processor — supplements the CPU
- Excellent for repetitive, identical operations on large datasets
- Originally for rendering graphics (millions of pixels simultaneously)
- Now used for: machine learning, AI training, scientific simulation, cryptocurrency mining
Multi-core & Parallel Systems
- Multi-core: multiple independent CPU cores on one chip. Each core can execute a separate instruction stream simultaneously.
- Parallel systems: multiple processors working on parts of the same problem. Can use threading on a single core.
- Both improve performance by doing work concurrently
| Type | Examples | How it works | Speed | Use case |
|---|---|---|---|---|
| Magnetic | HDD, tape | Magnetic coating on spinning platters; read/write head moves to sector | Slow (mechanical) | Cheap bulk storage, backups |
| Flash | SSD, USB drives, SD cards | NAND flash: electrons trapped in floating gate transistors; no moving parts | Very fast | OS drives, portable storage |
| Optical | CD, DVD, Blu-ray | Laser reads pits and lands on disc surface | Slow | Media distribution, archiving |
RAM — Random Access Memory
- Volatile — loses data when power removed
- Stores currently running programs and data
- Fast read/write access
- More RAM = can run more programs simultaneously
ROM — Read Only Memory
- Non-volatile — retains data without power
- Cannot be modified (Read Only)
- Stores BIOS/firmware
- Used in embedded systems where program never changes
Virtual Storage
- Uses secondary storage (hard disk) as if it were RAM
- Allows programs larger than physical RAM to run
- OS moves pages between RAM and disk as needed
- Page file: section of disk used as virtual memory
- Disk thrashing: computer freezes when pages swap constantly (too many programs, not enough RAM)
You need to justify why a specific device is suitable for a given scenario.
| Device | Type | Best suited for |
|---|---|---|
| Barcode scanner | Input | Fast, accurate product identification in retail |
| Touchscreen | Input/Output | Kiosks, mobile — intuitive, no extra hardware |
| Microphone | Input | Voice recognition, video conferencing |
| Digital camera | Input | Capturing images for processing |
| 3D printer | Output | Prototyping physical objects from digital models |
| Speaker | Output | Audio alerts, music, accessibility (text-to-speech) |
| Actuator | Output | Physical movement in robotics/automated systems |
- Memory management — allocates RAM to processes, handles virtual memory
- Process management / scheduling — decides which process runs and when
- Device management — manages hardware via device drivers
- File management — organises files on storage, handles permissions
- Security — manages user accounts, authentication, access control
- User interface — provides GUI or CLI
- Interrupt handling — responds to hardware/software interrupts
Types of Operating System
| Type | Description | Example |
|---|---|---|
| Distributed | Multiple networked computers work together, appear as one | Google's infrastructure |
| Embedded | Built into hardware; ROM; limited function; no UI | Washing machine, router |
| Multi-tasking | Multiple processes run concurrently (time-slicing) | Windows, macOS |
| Multi-user | Multiple users share one machine simultaneously | University mainframe |
| Real-time (RTOS) | Processes data and responds within a guaranteed timeframe | Pacemaker, autopilot |
Paging
- Memory divided into fixed-size blocks called pages
- Processes split into pages; loaded into any free page frames
- Avoids external fragmentation
- OS maintains a page table mapping logical → physical addresses
- Pages can be swapped to/from disk (virtual memory)
Segmentation
- Memory divided into variable-size logical segments (code, data, stack)
- Segments match the logical structure of a program
- More flexible than paging for the programmer
- Can cause external fragmentation (gaps between segments)
Virtual Memory
Part of the hard disk acts as overflow RAM. When RAM is full, inactive pages are moved to disk (page file). This allows programs larger than physical RAM to run.
BIOS
- Basic Input/Output System — stored in ROM
- First code run when computer powers on
- Runs POST (Power-On Self Test) to check hardware
- Loads the bootloader from storage, which loads the OS
- Manages low-level hardware configuration
The OS must share CPU time fairly between multiple processes. Scheduling algorithms decide the order and duration of execution.
| Algorithm | How it works | Pros | Cons |
|---|---|---|---|
| Round Robin | Each process gets an equal time slice. If not done, goes to back of queue. | Fair; all processes get CPU time; no starvation | High overhead switching; not optimal for short jobs |
| First Come First Served (FCFS) | Jobs processed in arrival order. Runs to completion. | Simple to implement; fair in order | Long jobs block short ones (convoy effect); no starvation prevention |
| Shortest Job First (SJF) | Always runs the job with shortest estimated time next. | Minimises average wait time | Long jobs may starve; requires knowing job lengths in advance |
| Shortest Remaining Time (SRT) | Preemptive SJF — if a new job arrives with shorter time remaining, it preempts. | Optimal average wait time | High overhead; starvation of long jobs |
| Multi-level Feedback Queue | Multiple queues with different priorities. Processes can move between queues. | Flexible; balances responsiveness and throughput | Complex to implement |
An interrupt is a signal sent to the CPU requesting its attention. After each FDE cycle, the CPU checks for interrupts.
How the CPU handles an interrupt:
CPU finishes current instruction
Checks interrupt register for pending interrupts
If interrupt higher priority than current task: current state saved to stack (PC, registers)
PC loaded with address of ISR (Interrupt Service Routine)
ISR executes to handle the interrupt
Interrupt flag reset; saved state restored from stack
Original program resumes from where it stopped
Types of Interrupt
- Printer completing a job
- Keyboard/mouse input received
- Peripheral unplugged
- Division by zero (software interrupt)
- Timer interrupt (used by scheduler)
- Power failure warning
Device Drivers
Software that allows the OS to communicate with hardware. Acts as a translator between generic OS calls and device-specific hardware instructions. Without a driver, the OS cannot use the device.
- Software emulation of a complete computer system
- Runs an OS within another OS (host and guest)
- The "host" runs the hypervisor which manages virtual machines
- Used for: testing software across OSes, running legacy software, server consolidation, sandboxing
- Also: intermediate code (e.g. JVM for Java) — code compiles to bytecode, which runs on a virtual machine independent of the hardware
- Translates entire HLL program to machine code in one go
- Produces a standalone executable
- Errors reported all at once after compilation
- Faster execution (already translated)
- Source code hidden from user
- Translates and executes line by line
- No executable produced — source needed each time
- Stops at first error — easier to debug
- Slower execution (translates every run)
- Source code visible
- Translates assembly language to machine code
- One-to-one mapping (each mnemonic → one instruction)
- Platform-specific output
Lexical Analysis — tokenisation: removes whitespace and comments; converts source code into tokens (keywords, identifiers, literals). Builds a symbol table.
Syntax Analysis — parsing: checks tokens against grammar rules of the language. Produces a parse tree (AST). Identifies syntax errors.
Semantic Analysis — checks meaning: type checking, variable declarations, scope rules. Ensures code makes sense logically.
Code Generation — translates the AST into machine code or intermediate code for the target platform.
Code Optimisation — improves efficiency of generated code: removes redundant instructions, simplifies loops, reduces memory use. Done without changing behaviour.
| Open Source | Closed Source (Proprietary) | |
|---|---|---|
| Source code | Publicly available | Hidden, restricted |
| Cost | Usually free | Usually paid |
| Modifiable? | Yes — users can edit and redistribute | No |
| Support | Community-driven | Official vendor support |
| Security | Many eyes find bugs fast, but vulnerabilities visible | Obscurity offers some protection |
| Examples | Linux, Firefox, Python | Windows, Microsoft Office, Photoshop |
Utilities
- System software with a specific maintenance purpose
- Examples: disk defragmenter (rearranges fragmented files for faster access), antivirus (detects/removes malware), file manager, backup software, disk compression
| Methodology | Approach | Best for | Drawback |
|---|---|---|---|
| Waterfall | Linear stages: requirements → design → implementation → testing → maintenance. Each stage must complete before the next. | Well-defined, stable requirements; fixed scope | Inflexible — going back is costly; client sees product late |
| Agile | Iterative sprints (2-4 weeks). Working software delivered frequently. Requirements can change. | Evolving requirements; client involvement | Hard to predict cost/timeline; needs constant client engagement |
| Extreme Programming (XP) | Agile variant: pair programming, test-driven development, continuous integration, frequent small releases | Small teams, high-quality code focus | Requires experienced developers; intensive client involvement |
| Spiral Model | Risk-driven: each cycle = risk analysis → prototype → evaluate. Combines waterfall + prototyping. | Large, high-risk projects | Complex; expensive risk management; not for small projects |
| RAD (Rapid Application Development) | Rapid prototyping; users involved throughout; iterative testing | Tight deadlines; UI-heavy applications | Requires user time; may sacrifice quality for speed |
Procedural / Imperative
- Sequence of instructions, executed top to bottom
- Uses procedures, functions, loops, conditionals
- Clear flow of control
- Examples: C, Pascal, BASIC
Object-Oriented (OOP)
- Programs built from objects — bundled data + behaviour
- Key concepts: encapsulation, inheritance, polymorphism
- Promotes reuse and modularity
- Examples: Python, Java, C++
Declarative
- Describe what you want, not how to do it
- The system works out the steps
- Examples: SQL ("SELECT * FROM table"), HTML, Prolog
Functional
- Programs as mathematical functions — input → output, no side effects
- Avoids mutable state and shared data
- Examples: Haskell, Erlang; functional features in Python
Lossless
- Original file can be perfectly reconstructed
- No data lost — just encoded more efficiently
- Used when: data integrity critical (text, executables, medical images)
- Examples: PNG, ZIP, FLAC
Run Length Encoding (RLE)
Replaces consecutive repeated values with a count + value pair.
Original: AAAABBCCCCCDD RLE: 4A 2B 5C 2D Saves: 13 chars → 8 values
Dictionary Coding
Frequently occurring strings are replaced by a short index. A dictionary maps index → original string. The compressed data + dictionary is stored.
Lossy
- Some data is permanently discarded
- Original cannot be recovered exactly
- Used when: small size matters more than perfection (images, audio, video)
- Examples: JPEG, MP3, MP4
When to use each
| Use lossy when… | Use lossless when… |
|---|---|
| Streaming video/audio | Compressing executables |
| Sharing photos online | Medical imaging |
| Storage is the priority | Text documents |
Symmetric Encryption
- Same key used to encrypt and decrypt
- Fast and efficient
- Problem: how to securely share the key? If intercepted during exchange, security broken
- Examples: AES, DES
Asymmetric Encryption
- Uses a key pair: public key (shared openly) + private key (secret)
- Anyone encrypts with public key; only private key holder can decrypt
- Solves key distribution problem — public key can be shared freely
- Slower than symmetric
- Used in: HTTPS, digital signatures, key exchange
- A hash function takes input data and produces a fixed-length hash value
- One-way — cannot reverse a hash to get the original data
- Same input always gives the same hash
- A collision = two different inputs produce the same hash (bad — should be rare)
Uses of Hashing
- Password storage: store hash of password, not the password itself. When user logs in, hash their input and compare to stored hash.
- Hash tables: use hash as an index to find data in O(1) time
- Data integrity: hash a file and send hash alongside it. Recipient hashes the received file — if hashes match, file wasn't tampered with
- Digital fingerprinting: uniquely identify files
- Flat file: single table — simple but prone to redundancy and anomalies
- Relational database: multiple linked tables — reduces redundancy
- Primary key: unique identifier for each record in a table (e.g. StudentID)
- Foreign key: primary key of another table, stored here to link tables
- Secondary key: non-unique field used to index/search (e.g. Surname)
- Entity: a thing about which data is stored (e.g. Student, Course)
Entity-Relationship (ER) Notation
- One-to-one: one student has one ID card
- One-to-many: one teacher teaches many students
- Many-to-many: many students take many courses (requires a junction/link table)
Referential Integrity
A foreign key cannot reference a primary key that doesn't exist. Prevents orphaned records. The database enforces this constraint automatically.
1NF (First Normal Form): All values are atomic (no lists/repeating groups). Each row is unique (has a primary key). No repeating columns.
2NF (Second Normal Form): In 1NF AND every non-key attribute is fully dependent on the whole primary key (no partial dependencies). Only matters if there's a composite key.
3NF (Third Normal Form): In 2NF AND no transitive dependencies — non-key attributes must depend only on the primary key, not on other non-key attributes.
SELECT (retrieve data)
SELECT Name, Grade FROM Students WHERE Grade >= 70 ORDER BY Grade DESC;
JOIN (combine tables)
SELECT Students.Name, Courses.Title FROM Students INNER JOIN Enrolments ON Students.StudentID = Enrolments.StudentID INNER JOIN Courses ON Enrolments.CourseID = Courses.CourseID;
INSERT (add record)
INSERT INTO Students (Name, Grade) VALUES ('Alice', 85);
UPDATE (change data)
UPDATE Students SET Grade = 90 WHERE StudentID = 3;
DELETE (remove record)
DELETE FROM Students WHERE StudentID = 3;
A transaction is a sequence of database operations treated as a single unit. ACID properties ensure data integrity even if something goes wrong mid-transaction.
| Property | Meaning |
|---|---|
| Atomicity | All operations in a transaction succeed, or none do. No partial transactions. |
| Consistency | Database always moves from one valid state to another. Rules/constraints are never violated. |
| Isolation | Concurrent transactions don't interfere with each other — each appears to run sequentially. |
| Durability | Once committed, changes persist even if the system crashes. Written to non-volatile storage. |
Data passes down the stack when sending, and up the stack when receiving. Each layer adds/removes its own header.
| Layer | Protocol examples | What it adds | What it does |
|---|---|---|---|
| Application | HTTP, HTTPS, FTP, POP3, IMAP, SMTP | Application data | Determines which protocol the application needs |
| Transport | TCP | Port number, packet number, total packets | Splits data into packets; handles retransmission of lost packets; end-to-end connection |
| Network | IP | Source & destination IP addresses | Logical addressing; routers operate here; determines route through network |
| Link | Ethernet, Wi-Fi | Source & destination MAC addresses | Physical addressing; identifies NIC cards; handles transmission on local network |
Packet Switching
Data split into packets. Each packet can take a different route. Reassembled at destination.
- Packets contain: header (source/dest IP, order, TTL), payload (data), trailer (checksum)
- More efficient — bandwidth shared
- Resilient — if one route fails, packets reroute
- Used by the Internet
Circuit Switching
A dedicated connection is established for the duration of communication.
- Data arrives in order — no reassembly needed
- Bandwidth wasted when nothing transmitted
- Both sides must transmit at same rate
- Used by: traditional phone networks (PSTN)
Firewalls
- Monitors and filters incoming/outgoing traffic using rules (packet filters)
- Examines: source IP, destination IP, port, protocol
- Dropped packets: silently discarded
- Rejected packets: sender is notified
- Can be hardware or software
Proxy Servers
- Acts as intermediary between user and internet
- Hides user's real IP address (anonymity)
- Can cache frequently accessed pages (speed)
- Can block access to specific sites (filtering)
Network Threats
- Malware: viruses, trojans, ransomware, spyware
- Phishing: fake emails/sites to steal credentials
- DDoS: flood server with requests to make it unavailable
- Man-in-the-middle: attacker intercepts communications
- SQL injection: malicious SQL in input fields to manipulate database
Network Hardware
| Device | Role |
|---|---|
| NIC | Connects device to network; has MAC address |
| Switch | Directs data to correct device on LAN using MAC addresses |
| Router | Connects networks; routes packets using IP addresses |
| WAP | Wireless access point; connects wireless devices to network |
| Gateway | Translates between different protocols/networks |
| Client-Server | Peer-to-Peer (P2P) | |
|---|---|---|
| Structure | Central server; clients connect to it | All devices equal — each is client AND server |
| Security | More secure; centralised control | Less secure; no central control |
| Backups | Centralised backups | Each device must backup independently |
| Cost | Expensive (dedicated server) | Cheap to set up |
| Failure | Server failure = all clients affected | No single point of failure |
| Examples | Websites, email servers | BitTorrent, some chat apps |
- Translates human-readable domain names (e.g. bbc.co.uk) into IP addresses
- Hierarchical structure: TLD (.uk) → 2LD (co) → subdomain (bbc)
- When you type a URL, your device queries a DNS server to get the IP, then connects to that IP
- DNS records cached locally to speed up future lookups
- HyperText Markup Language
- Defines structure and content of web pages
- Tags: <h1>, <p>, <a>, <img>, <table>
- Declarative — describes what to show
- Cascading Style Sheets
- Controls visual presentation (colours, fonts, layout)
- Separates style from content
- Selectors target HTML elements
- Scripting language for dynamic web pages
- Runs in the browser (client-side)
- Can modify HTML/CSS dynamically (DOM manipulation)
- Form validation, animations, API calls
| Client-Side | Server-Side | |
|---|---|---|
| Where it runs | In the user's browser | On the web server |
| Languages | HTML, CSS, JavaScript | PHP, Python, Node.js, SQL |
| Pros | Faster (no server round-trip); responsive UI | Secure (logic hidden); can access databases; consistent across browsers |
| Cons | Source code visible; dependent on client's hardware | Slower (network delay); more server load |
| Examples | Form validation, dropdown menus | Login authentication, database queries |
Indexing
- Web crawlers (spiders) follow links on pages and collect content
- Content is stored in an index (huge database mapping words → pages)
- When you search, the engine queries this index rather than the live web
PageRank Algorithm
- Developed by Google — ranks pages by importance
- More links pointing to a page = higher rank
- Links from high-rank pages count more
- Calculated iteratively — every page's rank depends on pages linking to it
- Used alongside content relevance to produce search results
| Type | Description | Example values |
|---|---|---|
| Integer | Whole numbers (positive, negative, zero) | 42, -7, 0 |
| Real / Float | Numbers with decimal/fractional part | 3.14, -0.5 |
| Boolean | True or False only (1 or 0) | True, False |
| Character | Single letter, digit or symbol | 'A', '3', '!' |
| String | Sequence of characters | "Hello", "abc123" |
Binary → Denary
Each bit position has a value (powers of 2). Sum the values where there is a 1.
128 64 32 16 8 4 2 1
1 0 1 1 0 1 0 1
= 128 + 32 + 16 + 4 + 1 = 181
Denary → Binary
Repeatedly divide by 2, read remainders bottom to top.
45 ÷ 2 = 22 r1
22 ÷ 2 = 11 r0
11 ÷ 2 = 5 r1
5 ÷ 2 = 2 r1
2 ÷ 2 = 1 r0
1 ÷ 2 = 0 r1
Read up: 101101 = 45
Binary ↔ Hexadecimal
Split binary into groups of 4 bits. Each group = one hex digit.
1011 0101
B 5 = 0xB5
Hex digits: 0-9, A=10, B=11,
C=12, D=13, E=14, F=15
Binary Addition
0110 0101 (101)
+ 0011 1010 ( 58)
-----------
1001 1111 (159)
Rules: 0+0=0, 0+1=1,
1+1=0 carry 1,
1+1+1=1 carry 1
Sign & Magnitude
- MSB (leftmost bit) = sign bit: 0 = positive, 1 = negative
- Remaining bits = magnitude
- +5 =
0000 0101, −5 =1000 0101 - Problem: two representations of zero (+0 and −0)
- Problem: arithmetic is complex
Two's Complement (preferred)
To negate: flip all bits, then add 1.
+5 = 0000 0101
Flip: 1111 1010
Add 1:1111 1011 = -5
Check: MSB 1 = negative
Value: -(128) + 64+32+16+8+2+1
= -128 + 123 = -5 ✓
- Only one representation of zero
- Normal addition works on positive and negative numbers
Floating point stores numbers as: mantissa × 2^exponent. Like scientific notation in binary.
Normalisation
A floating point number is normalised when the first bit after the binary point is different from the sign bit:
- Positive normalised: mantissa starts with
0.1xxx - Negative normalised: mantissa starts with
1.0xxx - Ensures maximum precision for a given number of bits
Precision vs Range
- More bits in mantissa → greater precision (more decimal places)
- More bits in exponent → greater range (larger/smaller numbers)
- Underflow: number too small to represent
- Overflow: number too large to represent
- Rounding errors occur due to finite precision
Shifts
- Left shift by 1 = multiply by 2
- Right shift by 1 = divide by 2 (integer)
- Bits shifted out are lost; zeros fill in
0000 1010 (10) left shift 1 0001 0100 (20)
Masks
- AND mask: use to isolate bits (set unwanted bits to 0)
- OR mask: use to force bits to 1
- XOR mask: use to flip specific bits
1100 1010 (value) AND 0000 1111 (mask) = 0000 1010 (lower 4 bits)
ASCII
- 7-bit encoding — 128 characters
- Covers: uppercase, lowercase, digits, punctuation, control characters
- Limitations: no non-Latin characters, no emoji
Unicode (UTF-8, UTF-16, UTF-32)
- Superset of ASCII — first 128 code points identical
- Supports 140,000+ characters including all world languages, emoji, symbols
- UTF-8 uses variable length: 1-4 bytes per character (efficient, backward compatible)
| Structure | Description | Key property |
|---|---|---|
| Array | Fixed-size ordered collection of same type. Can be 1D, 2D, 3D. | Fast random access O(1) by index; fixed size |
| Record | Collection of fields of different types (like a row in a database) | Groups related data of mixed types |
| List | Dynamic ordered collection; size can change | Mutable; can add/remove elements |
| Tuple | Ordered collection; fixed once created | Immutable — cannot be changed after creation |
Graph
- Nodes (vertices) connected by edges
- Directed: edges have a direction (one-way)
- Undirected: edges are two-way
- Weighted: edges have a numeric value (distance, cost)
- Represented as: adjacency matrix or adjacency list
- Used for: networks, maps, social connections
Hash Table
- Uses a hash function to map keys to array indices
- Average O(1) for insert/search/delete
- Collision: two keys hash to same index — resolved by chaining or open addressing
Binary Search Tree (BST)
- Left child < parent < right child
- In-order traversal gives sorted order
- Search: O(log n) on average, O(n) worst (unbalanced)
Differences: Tree vs Graph
- Tree: no cycles, one root, hierarchical, edges = n-1
- Graph: can have cycles, no root, can be disconnected, any number of edges
| A | B | AND | OR | XOR | NAND | NOR |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
NOT gate
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
OCR Notation
- NOT A = Ā (bar over) or ¬A
- A AND B = A · B or AB
- A OR B = A + B
- A XOR B = A ⊕ B
Boolean Laws — Must Know
| Law | AND form | OR form |
|---|---|---|
| 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 |
| Double neg. | Ā̄ = A | |
| Commutation | A·B = B·A | A+B = B+A |
| Association | A·(B·C) = (A·B)·C | A+(B+C) = (A+B)+C |
| Distribution | A·(B+C) = A·B + A·C | A+(B·C) = (A+B)·(A+C) |
De Morgan's Laws allow you to swap between AND/OR forms with negation:
// Law 1 — negate AND → OR NOT(A AND B) = NOT A OR NOT B Ā̄ · B̄ → Ā + B̄ // Law 2 — negate OR → AND NOT(A OR B) = NOT A AND NOT B Ā̄ + B̄ → Ā · B̄
Example Simplification
Simplify: A·B + A·C Factor out A (distribution): = A·(B + C) Another example: Ā·B + Ā·C = Ā·(B + C)
Karnaugh Maps (K-maps)
A grid method for simplifying Boolean expressions by grouping 1s in powers of 2 (1, 2, 4, 8...).
- Adjacent cells differ by one variable
- Group sizes must be powers of 2
- Larger groups = simpler result
- Groups can wrap around edges
- A logic circuit that stores one bit
- Two inputs: D (data) and CLK (clock)
- Output Q — the stored bit
- Q only updates on the rising edge of the clock
- At rising edge: Q ← D (Q takes the value of D)
- Between clock pulses: Q holds its value (memory!)
- Built from 4 NAND gates
- Sets of flip-flops form registers
Truth Table
| CLK edge | D | Q (next) |
|---|---|---|
| Rising ↑ | 0 | 0 |
| Rising ↑ | 1 | 1 |
| Not rising | X | No change |
Half Adder
Adds two 1-bit values. Outputs: Sum and Carry.
- Sum = A XOR B
- Carry = A AND B
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Full Adder
Adds three inputs: A, B, and Carry-in. Outputs: Sum, Carry-out.
- Made of two half adders + an OR gate
- Can be chained to add multi-bit numbers
- Sum = A XOR B XOR Cin
- Carry-out = (A AND B) OR (Cin AND (A XOR B))
| A | B | Cin | Sum | Cout |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
| Act | Year | What it covers | Key offences/provisions |
|---|---|---|---|
| Data Protection Act | 1998 (GDPR 2018) | How personal data is collected, stored and used by organisations | Data must be: collected lawfully, used only for stated purpose, kept accurate, not kept longer than necessary, kept secure, not transferred outside EU without adequate protection. Individuals have right to access their data. |
| Computer Misuse Act | 1990 | Prevents unauthorised access or modification to computer systems | Three offences: (1) Unauthorised access to computer material, (2) Unauthorised access with intent to commit further offences, (3) Unauthorised modification of computer contents (e.g. installing malware, deleting files) |
| Copyright, Designs & Patents Act | 1988 | Protects intellectual property — software, music, films, code | Illegal to copy, distribute or modify software without licence. Applies to piracy, illegal downloads. Open source licences (GPL, MIT) are legal frameworks under this act. |
| Regulation of Investigatory Powers Act (RIPA) | 2000 | Regulates surveillance and investigation powers of public bodies | Allows government/police to intercept communications lawfully. ISPs may be required to retain communications data. Balance between national security and individual privacy. |
Computers in the Workforce
- For: Automation increases productivity, reduces costs, improves accuracy, frees humans for creative work
- Against: Job displacement, widening inequality, deskilling, loss of human judgment in important decisions
Automated Decision Making
- For: Consistent, fast, unbiased (no human prejudice), data-driven
- Against: Algorithmic bias (reflects biased training data), lack of accountability, no empathy, opaque "black box" decisions
- Examples: credit scoring, parole decisions, hiring algorithms
Artificial Intelligence
- For: Medical diagnosis, climate modelling, accessibility, scientific research
- Against: Deepfakes/misinformation, autonomous weapons, surveillance, job losses, existential risk debates
Environmental Effects
- Data centres consume enormous energy — large carbon footprint
- E-waste from discarded devices — toxic materials
- But: Computing enables remote work (less travel), smart grids, environmental monitoring
Censorship & the Internet
- For censorship: Prevents harmful content (child abuse, terrorism), protects vulnerable users
- Against censorship: Suppresses free speech, government control, disproportionate blocking
Monitoring Behaviour & Personal Data
- Cookies, tracking pixels, location data, social media profiling
- For: Personalisation, targeted services, fraud detection
- Against: Privacy invasion, Cambridge Analytica-style manipulation, lack of consent
Piracy & Offensive Communications
- Piracy harms creators but raises access issues (cost barriers)
- Online abuse, trolling — platform responsibility debate