C++ (reference), Java (object references), Pascal (var parameters)
Call‑by‑name / Call‑by‑need
Expression re‑evaluated each use (lazy)
Depends on the expression; rarely used in mainstream A‑Level languages
Algol, Haskell (call‑by‑need)
Call‑by‑Value Example (Python‑style pseudocode)
def increment(x):
x = x + 1 # only the local copy changes
return x
a = 5
b = increment(a) # a is still 5, b becomes 6
Call‑by‑Reference Example (C++‑style pseudocode)
void doubleValue(int &n) { // & denotes a reference
n = n * 2; // modifies the original variable
}
int a = 4;
doubleValue(a); // a is now 8
Default Parameters (Python‑style)
def greet(name, greeting="Hello"):
print(f"{greeting}, {name}!")
greet("Alice") # Hello, Alice!
greet("Bob", "Hi") # Hi, Bob!
Parameter Scope & Lifetime
Parameters are local to the procedure in which they are declared.
Lifetime starts on entry to the procedure and ends on return.
When passed by reference, the reference itself has the same lifetime, but it points to a variable that may outlive the call.
Design‑Evaluation Activity (AO3)
Write a procedure swap(a, b) that exchanges the values of two integers.
Implement it once using call‑by‑value and once using call‑by‑reference.
Analyse which version is more efficient and which better satisfies the requirement “the caller’s variables must be swapped”.
Worked Example – Bubble Sort (Pass‑by‑Reference)
proc bubbleSort(arr: list ref):
n = length(arr)
repeat
swapped = false
for i = 1 to n-1 do
if arr[i] > arr[i+1] then
temp = arr[i]
arr[i] = arr[i+1]
arr[i+1] = temp
swapped = true
end if
end for
n = n - 1
until not swapped
end proc
# Main program
myList = [5, 2, 9, 1, 6]
bubbleSort(myList) # myList is sorted in‑place
Key Take‑aways
Parameters enable procedures to operate on external data without hard‑coding values.
Choose the appropriate passing mechanism to control whether changes affect the caller.
Default parameters reduce code duplication and improve readability.
Always respect scope and lifetime when designing procedures.
12. Software Development Life‑Cycle (SDLC)
Waterfall model – sequential phases (Requirements → Design → Implementation → Testing → Maintenance). Advantages: clear documentation, easy to manage. Disadvantages: inflexible, late discovery of errors.
Iterative / Incremental model – develop a core system, then add functionality in cycles. Advantages: early user feedback, risk reduction. Disadvantages: requires good planning of iterations.
Rapid Application Development (RAD) – heavy use of prototyping and CASE tools. Advantages: fast delivery, high user involvement. Disadvantages: may compromise on scalability and documentation.
Agile principles (Scrum) – short sprints, daily stand‑ups, product backlog. Emphasises adaptability and customer collaboration.
Evaluation criteria (AO3):
Project size and complexity.
Stakeholder requirements for documentation vs. speed.
Resource availability (time, people, tools).
Risk profile – safety‑critical vs. commercial web app.
A‑Level Extensions (Units 13‑20)
13. User‑Defined Types & Abstract Data Types (ADTs)
Structures / records – grouping heterogeneous data (e.g., struct Student { id:int; name:string; GPA:float; }).
Classes (OOP) – encapsulation of data (attributes) and behaviour (methods).
Abstract Data Types – defined by operations, not implementation (e.g., Stack, Queue, List, Map).
Encapsulation & information hiding – use of private/public access specifiers.
Example: Stack ADT (pseudocode)
type Stack
procedure push(s: Stack ref, x)
procedure pop(s: Stack ref) returns element
function top(s: Stack) returns element
function empty(s: Stack) returns boolean
end type
14. File Organisation & Random Access
Sequential files – records stored one after another; efficient for batch processing.
Random‑access files – direct access via file pointer; requires fixed‑length records or an index.
Indexing techniques:
Primary index – sorted on key field.
Secondary index – separate structure for non‑key fields.
B‑tree / B+‑tree – balanced tree for large data sets.
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.