| Syllabus Code | Topic Covered in These Notes | Status |
|---|---|---|
| 19.1 – Algorithms: Searching | Linear search, binary search (iterative & recursive), complexity analysis, testing, selection criteria | ✓ Complete |
| 10.1 – Data Structures: Arrays | Both algorithms are presented for one‑dimensional arrays (indexing, length) | ✓ Complete |
| 9.2 – Algorithm Design & Problem Solving | Algorithmic approach, divide‑and‑conquer, sequential scan, recursion, optimisation | ✓ Complete |
| Other AS (1‑12) & A‑Level (13‑20) topics | Not covered here – see the “Quick‑Reference Checklist” below | ✗ Incomplete |
| Syllabus Block (AS) | What to Verify in Your Notes | Typical Gaps & How to Fix Them |
|---|---|---|
| 1 Information Representation | • Binary, hexadecimal, BCD, two’s‑complement arithmetic • ASCII/Unicode, colour‑depth, resolution, file‑size calculations • Lossy vs. lossless compression (RLE, Huffman, JPEG, MP3) | *Missing binary‑base conversions* → add worked examples (e.g. *No compression case‑studies* → include a short activity comparing PNG vs. JPEG file sizes. |
| 2 Communication | • LAN/WAN concepts, topologies, client‑/server vs. peer‑to‑peer • IP addressing (IPv4/IPv6, subnetting, public‑/private, static vs. dynamic) • DNS, URL structure, Ethernet/CSMA‑CD, wireless vs. wired, cloud computing | *Subnet‑mask calculations often omitted* → add a subnet‑mask worksheet. *Cloud‑computing only mentioned in passing* → give a real‑world example (e.g. SaaS vs. IaaS). |
| 3 Hardware | • CPU, registers, ALU, control unit, bus architecture • RAM/ROM types (SRAM, DRAM, PROM, EPROM, EEPROM) • Logic‑gate symbols, truth tables, simple combinational circuits | *Logic‑circuit design rarely shown* → insert a design task for a 2‑bit adder. *Difference between SRAM/DRAM* → provide a comparison table (speed, cost, usage). |
| 4 Processor Fundamentals | • Von Neumann model, fetch‑execute cycle, interrupts • Two‑pass assembler process, addressing modes (immediate, direct, indirect, indexed) • Bit‑shifts, masks, logical/arith‑shift, set‑/clear‑bit operations | *Address‑mode examples often missing* → give a short program that uses indexed addressing. *Bit‑mask exercises* → add a “set the 3rd bit” mini‑task. |
| 5 System Software | • OS functions (memory, file, process, I/O management) • Translators (assembler, compiler, interpreter) • IDE features, debugging tools | *OS‑function diagrams rarely included* → add a labelled diagram of the OS components. *Debugging strategies not explicit* → provide a checklist for systematic testing. |
Linear search examines each element of a collection in order until the target value is found or the end of the collection is reached. It works on any data set – sorted or unsorted.
function linearSearch(arr, target):
// arr – one‑dimensional array, 0‑based indexing
for i ← 0 to length(arr)‑1 do
if arr[i] = target then
return i // index of first occurrence
return -1 // target not present
function linearSearchRec(arr, target, i):
if i = length(arr) then
return -1 // reached end – not found
if arr[i] = target then
return i
return linearSearchRec(arr, target, i+1)
| Metric | Best | Average | Worst |
|---|---|---|---|
| Time (comparisons) | O(1) | O(n) | O(n) |
| Space | O(1) | O(1) | O(1) (iterative) / O(n) (recursion depth) |
Search for 23 in L = [5, 12, 23, 7, 19]
| i | arr[i] | Comparison (arr[i]=target?) | Result |
|---|---|---|---|
| 0 | 5 | No | continue |
| 1 | 12 | No | continue |
| 2 | 23 | Yes | return 2 |
length‑1 → return –1.low points to the first candidate, high to the last.function binarySearch(arr, target):
low ← 0
high ← length(arr)‑1
while low ≤ high do
mid ← floor((low + high) / 2)
if arr[mid] = target then
return mid
else if arr[mid] < target then
low ← mid + 1
else
high ← mid – 1
return -1
function binarySearchRec(arr, target, low, high):
if low > high then
return -1 // not found
mid ← floor((low + high) / 2)
if arr[mid] = target then
return mid
else if arr[mid] < target then
return binarySearchRec(arr, target, mid+1, high)
else
return binarySearchRec(arr, target, low, mid‑1)
| Metric | Best | Average | Worst |
|---|---|---|---|
| Time (comparisons) | O(1) | O(log₂ n) | O(log₂ n) |
| Space | O(1) | O(1) (iterative) / O(log n) (recursion depth) | O(log n) |
Search for 23 in S = [5, 7, 12, 19, 23, 31, 42]
| Step | low | high | mid | S[mid] | Action |
|---|---|---|---|---|---|
| 1 | 0 | 6 | 3 | 19 | 19 < 23 → low = 4 |
| 2 | 4 | 6 | 5 | 31 | 31 > 23 → high = 4 |
| 3 | 4 | 4 | 4 | 23 | found → return 4 |
low = 0, high = -1 → loop condition false → return –1.low > high → return –1.| Criterion | Linear Search | Binary Search |
|---|---|---|
| Data order | Works on unsorted or sorted data. | Requires sorted data (or a sorted view). |
| Size of data set (n) | Efficient for very small n (e.g., n ≤ 10). | Preferred when n is large (log₂ n ≪ n). |
| Frequency of searches | One‑off or infrequent searches. | Repeated searches on the same sorted collection. |
| Memory constraints | O(1) auxiliary space, no recursion. | Iterative version O(1); recursive version O(log n) stack. |
| Implementation simplicity | Very simple – ideal for early programming stages. | More complex – careful index handling required. |
For each algorithm, students should produce a concise test plan covering the following categories:
| Test # | Array (sorted) | Target | Expected index | Result |
|---|---|---|---|---|
| 1 | [2, 4, 6, 8, 10] | 6 | 2 | ✓ |
| 2 | [2, 4, 6, 8, 10] | 2 | 0 | ✓ |
| 3 | [2, 4, 6, 8, 10] | 10 | 4 | ✓ |
| 4 | [] | 5 | -1 | ✓ |
| 5 | [1, 3, 3, 3, 7] | 3 | 1‑3 (any) | ✓ |
| 6 | [1, 3, 5, 7, 9] | 4 | -1 | ✓ |
Prompt: Given the array A = [14, 7, 19, 3, 11], trace the execution of linear search to find the value 3. Show the values of the loop index i and the comparison result at each iteration, and state the final index returned.
Mark Scheme (6 marks):
i = 0 (1 mark)A[0]=14 ≠ 3 – continue (1 mark)A[1]=7 ≠ 3 – continue (1 mark)A[2]=19 ≠ 3 – continue (1 mark)A[3]=3 = 3 – found (1 mark)3 (1 mark)Prompt: Write pseudocode for a recursive binary search that returns the index of the first occurrence of target in a sorted array arr. Include a brief comment on its time‑complexity.
Mark Scheme (8 marks):
low > high) – 1 markmid – 1 markmid – 1 markarr[mid] < target – 1 markarr[mid] > target – 1 markmid‑1 when a match is found) – 2 marksPrompt: A school database stores 12 000 student IDs in a sorted array. The system must answer 10 000 look‑up queries per day. Which searching algorithm would you recommend and why? (4 marks)
Mark Scheme (4 marks):
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.