| Syllabus Area | Present in These Notes | What to Add Elsewhere |
|---|---|---|
| 10.1 Data Types & Records | Brief reminder added (see §2) | Full list of primitive types and record structures (topic 10.1) – see the “Data Types” hand‑out. |
| 10.2 Arrays | Definition, terminology, static vs dynamic, 1‑D/2‑D, bounds, address formulas, initialisation (including literals), lower‑bound handling. | None. |
| 10.3 Files | Link added (see §8) | Full file‑handling pseudocode and examples. |
| 10.4 Abstract Data Types (ADT) | Stack/queue implementation using arrays (see §9) | Detailed ADT specifications and other implementations. |
| 12.1 Program Development Life‑Cycle | Note on where array design fits (see §7) | Full PDLC diagram and description. |
| 12.2 Program Design (Structure charts, state‑transition diagrams) | Simple structure‑chart example (see §7) | Comprehensive design techniques. |
| 12.3 Testing & Maintenance | Boundary‑value testing advice (see §10) | Full testing strategy. |
| A‑Level extensions (Topics 13‑20) | “Next steps” box (see §11) | Separate A‑Level notes on recursion, exception handling, etc. |
int in Java.float/double.true/false.All elements of an array must be of the same primitive type (or the same user‑defined record type).
length − 1 for zero‑based arrays.new int[n], ArrayList, Python list).for loop.DECLARE scores[5] OF INTEGER // length = 5, lower bound = 0SET scores[0] ← 0
SET scores[1] ← 0
SET scores[2] ← 0
SET scores[3] ← 0
SET scores[4] ← 0 // explicit initialisation
// static size, default initialisation (0 for int)int[] scores = new int[5];
// static size with literal initialisation
int[] marks = {78, 85, 92, 67, 81};
// dynamic size (run‑time value)
int n = Integer.parseInt(input());
int[] data = new int[n];
// resizable collection (often used in A‑Level questions)
ArrayList<Integer> list = new ArrayList<>();
# list of length n, initially all zerosscores = [0] * n
# literal initialisation
marks = [78, 85, 92, 67, 81]
# dynamic growth
marks.append(90)
For element i (zero‑based) in an array with element size s bytes and base address B:
\[
\text{address}(i) = B + i \times s
\]
For an array A with R rows, C columns, element size s, and base address B:
\[
\text{address}(i,j) = B + (i \times C + j) \times s
\]
where i = row index, j = column index (both zero‑based).
\[
\text{address}(i,j) = B + (j \times R + i) \times s
\]
Array A is a 4 × 5 integer matrix, each integer occupies 4 bytes, base address 0x1000.
A[2][3]:\[
\text{offset} = (2 \times 5 + 3) \times 4 = 13 \times 4 = 52\text{ bytes}
\]
\[
\text{address} = 0x1000 + 52 = 0x1034
\]
A[2][3] resides at memory address 0x1034.// Java example – illegal accessint[] ages = {12, 15, 17, 19, 21}; // length = 5
int value = ages[5]; // index 5 is out of bounds
Running the fragment throws ArrayIndexOutOfBoundsException because the valid indices are 0 ≤ index < 5. In an exam answer you should state:
ages[5], which lies outside the valid bounds (0 ≤ index < 5). This causes an out‑of‑bounds error.”Arrays are often used as buffers when reading from or writing to files. A typical pattern is:
// PseudocodeDECLARE buffer[100] OF INTEGER
OPEN file FOR READ
WHILE NOT EOF(file) DO
READ nextValue FROM file
IF index < 100 THEN
SET buffer[index] ← nextValue
INCREMENT index
ENDIF
ENDWHILE
CLOSE file
See the “Files” hand‑out for full syntax and error handling.
DECLARE stack[SIZE] OF INTEGERDECLARE top ← -1 // empty stack
PROCEDURE push(x)
IF top = SIZE‑1 THEN
OUTPUT "Stack overflow"
ELSE
top ← top + 1
SET stack[top] ← x
ENDIF
ENDPROCEDURE
PROCEDURE pop() RETURNS INTEGER
IF top = -1 THEN
OUTPUT "Stack underflow"
RETURN -1 // sentinel value
ELSE
SET result ← stack[top]
top ← top - 1
RETURN result
ENDIF
ENDPROCEDURE
DECLARE queue[SIZE] OF INTEGERDECLARE front ← 0, rear ← -1, count ← 0
PROCEDURE enqueue(x)
IF count = SIZE THEN
OUTPUT "Queue full"
ELSE
rear ← (rear + 1) MOD SIZE
SET queue[rear] ← x
count ← count + 1
ENDIF
ENDPROCEDURE
PROCEDURE dequeue() RETURNS INTEGER
IF count = 0 THEN
OUTPUT "Queue empty"
RETURN -1
ELSE
SET result ← queue[front]
front ← (front + 1) MOD SIZE
count ← count - 1
RETURN result
ENDIF
ENDPROCEDURE
These examples illustrate how arrays underpin many abstract data types examined in the syllabus.
length‑1.-1 and length – should trigger an out‑of‑bounds error.i <= length instead of i < length.int) are as expected unless overridden.| Term | Exam‑relevant Definition |
|---|---|
| Array | Ordered collection of same‑type elements stored contiguously. |
| Element | Single value located at a particular index. |
| Index / Subscript | Integer used to locate an element; first index is usually 0. |
| Lower bound | Smallest legal index (often 0, but may differ in some languages). |
| Upper bound | Largest legal index, equal to length − 1 for zero‑based arrays. |
| Length / Size | Number of elements an array can contain. |
| Dimension | Number of indices required to address an element (1‑D, 2‑D, …). |
| Static array | Size fixed at compile time; cannot be resized later. |
| Dynamic array | Size determined or altered at run time (e.g., new int[n], ArrayList, Python list). |
| Row‑major order | Rows stored consecutively in memory. |
| Column‑major order | Columns stored consecutively in memory. |
| Declaration | Statement that defines an array’s type and size. |
| Initialisation | Assigning initial values, either at declaration (literals) or later. |
| Access / Retrieval | Reading a value using its index. |
| Assignment / Update | Writing a new value using its index. |
| Iteration | Processing each element, typically with a for loop. |
| Bounds checking | Run‑time test that an index lies within valid limits. |
| Out‑of‑bounds error | Exception or undefined behaviour caused by an illegal index. |
These notes cover the AS‑Level requirements; consult the A‑Level extensions for deeper exploration.
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.