Choose and design an appropriate user‑defined data type for a given problem, justify the design against the Cambridge 9618 syllabus, and implement it in pseudo‑code and a chosen programming language.
Book) is easier to understand than a collection of unrelated variables.| Category | Definition | Typical Use in A‑Level |
|---|---|---|
| Enumerated type (enum) | A set of named constant values. | Days of the week, traffic‑light colours, menu options. |
| Record / Structure | A collection of fields of possibly different primitive types. | Library book, student record, exam result. |
| Class / Object | A record plus associated behaviour (methods) and optional inheritance. | When data and operations must be bundled, e.g., a Book class with borrow() and return() methods. |
| Step | Action | Result |
|---|---|---|
| 1 | Identify entity | Book – needs title, author, ISBN, availability, borrower ID. |
| 2 | Choose representation | Record (fields of different primitive types). |
| 3 | Define type (pseudo‑code) |
|
| 4 | Write operations |
|
| 5 | Test with sample data | Create three Book instances, borrow one, return another, verify field updates. |
Java
public class Book {
private String title;
private String author;
private String isbn;
private boolean isAvailable = true;
private int borrowerID = 0;
public Book(String title, String author, String isbn) {
this.title = title;
this.author = author;
this.isbn = isbn;
}
public void borrow(int id) {
if (isAvailable) {
isAvailable = false;
borrowerID = id;
}
}
public void returnBook() {
isAvailable = true;
borrowerID = 0;
}
public void display() {
System.out.println(title + " – " + author + " (ISBN: " + isbn + ")");
System.out.println(isAvailable ? "Available" : "Borrowed by " + borrowerID);
}
}
Python (dataclass)
from dataclasses import dataclass
@dataclass
class Book:
title: str
author: str
isbn: str
is_available: bool = True
borrower_id: int = 0
def borrow(self, borrower_id: int):
if self.is_available:
self.is_available = False
self.borrowerid = borrowerid
def return_book(self):
self.is_available = True
self.borrower_id = 0
def display(self):
print(f"{self.title} – {self.author} (ISBN: {self.isbn})")
print("Available" if self.isavailable else f"Borrowed by {self.borrowerid}")
Adding a new attribute
If the library now needs to store the publication year, simply add year: integer (or a new field in Java/Python). All existing code that creates or manipulates Book objects continues to work; only the type definition changes.
type TrafficLight is enum { Red, Amber, Green }
Java
public enum TrafficLight {
RED, AMBER, GREEN
}
Python
from enum import Enum
class TrafficLight(Enum):
RED = 1
AMBER = 2
GREEN = 3
class Book
// attributes
title : string
author : string
isbn : string
isAvailable : boolean
borrowerID : integer
// constructor
function Book(t:string, a:string, i:string)
title := t
author := a
isbn := i
isAvailable := true
borrowerID := 0
end function
// methods
procedure borrow(id:integer)
if isAvailable then
isAvailable := false
borrowerID := id
end if
end procedure
procedure return()
isAvailable := true
borrowerID := 0
end procedure
procedure display()
output title, " by ", author, " (ISBN:", isbn, ")"
if isAvailable then
output " – Available"
else
output " – Borrowed by ", borrowerID
end if
end procedure
end class
borrow and return modify state; display reads it.1101₂.Example: 59 → 0101 1001 (5 = 0101, 9 = 1001).
Example: 'A' → 0100 0001₂.
Code point U+1F600 (😀) = binary 0001 1111 0110 0000 0000. UTF‑8 bytes:
11110000100111111001100010000000Convert the Unicode code point U+00E9 (é) to UTF‑8 bytes.
| Network | Typical Speed | Media | Common Devices |
|---|---|---|---|
| LAN (Local Area Network) | 10 Mbps – 10 Gbps | Twisted‑pair, fibre, Wi‑Fi | Switches, routers, NICs |
| WAN (Wide Area Network) | 56 kbps – 1 Gbps | Coax, fibre, satellite | Modems, routers |
| Preamble (7 bytes) | SFD (1 byte) | Destination MAC (6 bytes) |
| Source MAC (6 bytes) | Type/Length (2 bytes) | Data (46‑1500 bytes) |
| CRC (4 bytes) |
CSMA/CD (Carrier Sense Multiple Access with Collision Detection) lets devices listen before transmitting; if a collision occurs, they wait a random back‑off time before retrying.
192.168.1.10)./24 (255.255.255.0) leaves 8 bits for hosts → 2⁸‑2 = 254 usable addresses.Given the network 10.0.0.0/22, how many usable host addresses are available?
www.example.com) to an IP address.protocol://host:port/path?query#fragment.| Model | What is Provided | Typical Example |
|---|---|---|
| IaaS (Infrastructure as a Service) | Virtual machines, storage, networking | Amazon EC2, Microsoft Azure VMs |
| PaaS (Platform as a Service) | Runtime environment, middleware, databases | Google App Engine, Heroku |
| SaaS (Software as a Service) | Fully functional applications | Google Workspace, Microsoft 365 |
| Characteristic | SRAM | DRAM |
|---|---|---|
| Cell structure | 6 transistors (no capacitor) | 1 transistor + 1 capacitor |
| Access time | ~10 ns (fast) | ~50‑100 ns (slower) |
| Density | Low (fewer cells per chip) | High (compact cells) |
| Power consumption | Higher (continuous power) | Lower (needs refresh) |
| Typical use | CPU cache | Main memory |
Specialised computers built into devices (e.g., microwaves, automotive controllers). Characteristics: limited resources, real‑time constraints, often use microcontrollers with integrated RAM/ROM.
A 5‑stage pipeline (IF, ID, EX, MEM, WB) allows overlapping of instruction phases, increasing throughput.
• Data hazard – an instruction depends on the result of a previous one.
• Control hazard – branch instructions change the flow.
• Structural hazard – hardware resources are insufficient.
Speed‑up = 1 / [(1‑P) + P / S] where P is the proportion of the program that can be parallelised and S is the speed‑up of the parallel portion. Demonstrates diminishing returns as P approaches 1.
| Algorithm | Key Idea | Typical Use |
|---|---|---|
| FCFS (First‑Come‑First‑Served) | Run processes in arrival order. | Batch systems. |
| Round‑Robin (RR) | Each process gets a fixed time‑slice (quantum). | Time‑sharing, interactive systems. |
| Shortest‑Job‑First (SJF) | Run the process with the smallest CPU burst first. | Minimise average waiting time (non‑preemptive). |
| Priority Scheduling | Higher‑priority processes run first. | Real‑time or mixed‑criticality systems. |
Compute the simple 8‑bit checksum for the byte sequence 0x12, 0xAF, 0x34 by summing the bytes modulo 256.
A secondary school must choose a learning‑management system. Discuss the advantages of using an open‑source solution (cost, customisation, community support) against a proprietary product (vendor support, guaranteed updates). Conclude with a justified recommendation.
CREATE TABLE – defines a new table and its fields.ALTER TABLE – modifies structure (add/drop column).DROP TABLE – removes a table.INSERT INTO – adds a new record.SELECT – queries data.UPDATE – modifies existing records.DELETE – removes records.CREATE TABLE ExamResult (
studentID INT PRIMARY KEY,
name VARCHAR(50),
mark1 INT,
mark2 INT,
mark3 INT
);
INSERT INTO ExamResult VALUES (101, 'Alice', 85, 90, 78);
SELECT studentID, name,
(mark1 + mark2 + mark3) / 3.0 AS average
FROM ExamResult;
borrow() on a fresh Book).Write a small driver program that stores several objects (e.g., a list of Book records) in an array or collection, performs a sequence of operations, and checks the final state.
Requirements
ExamResult.studentID : integername : stringmarks : array[1..3] of integertype ExamResult is record
studentID : integer
name : string
marks : array[1..3] of integer
end record
function average(r: ExamResult) : real
total := 0
for i from 1 to 3 do
total := total + r.marks[i]
end for
return total / 3.0
end function
average returns 84.33.average.public class ExamResult {
private int studentID;
private String name;
private int[] marks = new int[3];
public ExamResult(int id, String name, int[] marks) {
this.studentID = id;
this.name = name;
System.arraycopy(marks, 0, this.marks, 0, 3);
}
public double average() {
int total = 0;
for (int m : marks) total += m;
return total / 3.0;
}
// getters omitted for brevity
}
from dataclasses import dataclass
from typing import List
@dataclass
class ExamResult:
student_id: int
name: str
marks: List[int] # expects three integers
def average(self) -> float:
return sum(self.marks) / 3.0
Your generous donation helps us continue providing free Cambridge IGCSE & A-Level resources, past papers, syllabus notes, revision questions, and high-quality online tutoring to students across Kenya.