19. Computational Thinking and Problem-Solving
Recursion, ADTs in code (stack, queue, linked list, binary tree, dictionary, hash table), searching and sorting (binary search, insertion sort, bubble sort), and Big O.
Statometer80BankerNext Paper 484%Everything for this topic — study hub
A2 Level · 9618 · Paper 4
Statometer — what 64 real papers say about this topic and each of its 3 syllabus bullets
Banker · #2 of 8 in A2 Level · recomputed with every new session
Set in nearly every paper and worth a big slice of it — revise first, expect it.
- Next Paper 4
- 84%
- 8 in 10 chance it is set
- Marks a paper
- 29.4 / 75
- 39% of Paper 4 · fair share 50%
- Appeared in
- 28 / 32
- Paper 4 sittings 2021–2026
- Last set
- May/Jun 2026
- 9618/43 · Q3 · 25 marks · 6-series streak
What the papers say
- Set in 28 of 32 Paper 4 sittings — about 9 papers in 10.
- Worth about 29.4 marks a paper (39% of Paper 4).
- Also turns up in Paper 3 (100% of sittings, ~13.3 marks) — usually inside a scenario question.
- Last set May/Jun 2026 · 9618/43 · Q3 for 25 marks — in the most recent series.
- Set in each of the last 6 series without a miss.
- Steady at around 33.7 marks a paper year on year.
- Lives on “Write” and “Complete” — 94% of its questions: you must produce something — code, a diagram, a table — practise doing it, not reading it.
- 74% of its questions are set out as code, pseudocode or a table to complete.
- Most of its marks (79%) come in extended questions of 12+ marks — plan the answer before writing.
- Its biggest question so far: 30 marks (May/Jun 2025 · 9618/41 · Q3).
- Inside the topic, §19.1 Algorithms carries the most marks (74%) and §19.2 Recursion the least (8%).
- It is examined mostly as AO3 (Design, program & evaluate, 68%) — you must build it — write the pseudocode or program, design the structure.
- The examiner has commented on 52 of its questions — read “What the examiner said” before you practise.
Command words
Share of questions using the word (a question can use several). What each wants →
Question shapes
- ≤ 6 mk11
- 7–9 mk21
- 10–12 mk11
- 13–15 mk4
- 16+ mk43
Average 15.2 marks a question · 20% with a figure or table · 74% with code · biggest 30 marks
Assessment objectives — how it is examined
Every part of every current-syllabus question filed under Cambridge's AO1 / AO2 / AO3 (from its command word and what it asks you to do), so you know whether this topic pays for definitions, for applying, or for judging and building.
- AO1 Knowledge & understanding
- AO2 Apply & analyse
- AO3 Design, program & evaluate
Paper 4 as a whole
| Paper 4 | Syllabus | Measured |
|---|---|---|
| AO1 Knowledge & understanding | 0% | 0% |
| AO2 Apply & analyse | 0% | 1% |
| AO3 Design, program & evaluate | 100% | 99% |
Syllabus = Cambridge's grid; measured = the bank's current-syllabus papers.
Inside the topic — every syllabus bullet, measured
Each part of each question is filed under the bullet it examines; the numbers are per Paper 4 sitting, exactly like the topic's. Open a bullet for its own Statometer.
19.1Algorithms#2 of 7 on Paper 4Banker · 9177% next paper17.4 marks25/32 sittings↗ May/Jun 2026Banker · 9177%
17.4 · 74% of topic25/32May/Jun 2026latest series · ↗Asked in nearly every paper — the bullet to know cold.Syllabus: linear and binary search (conditions, performance); insertion and bubble sort; finding, inserting and deleting items in stacks, queues, linked lists and binary trees; graphs as ADTs
- Next Paper 4
- 77%
- 8 in 10
- Marks a paper
- 17.4
- 23% of the paper · 74% of the topic
- Asked in
- 25 / 32
- Paper 4 sittings · 81 questions
- Last asked
- May/Jun 2026
- 9618/43 · Q3 · 6 marks · 5-series streak
- Asked in 25 of 32 Paper 4 sittings — about 8 papers in 10.
- About 17.4 marks a paper (23% of Paper 4; 74% of the topic's marks across its 3 bullets).
- Last asked May/Jun 2026 · 9618/43 · Q3 (6 marks) — in the most recent series.
- Asked in each of the last 5 series.
- Rising: 13.2 → 21.6 marks a paper.
- Usually “Write” or “Complete”: you must produce something — code, a diagram, a table — practise doing it, not reading it.
- Biggest chunk of marks so far: 28 in May/Jun 2025 · 9618/43 · Q3.
- It is examined mostly as AO3 (Design, program & evaluate, 62%), the rest AO2 (23%) — you must build it — write the pseudocode or program, design the structure.
Last 12 sittings↗ RisingAssessment objectives
AO1 14%AO2 23%AO3 62%- AO1 Knowledge & understanding
- AO2 Apply & analyse
- AO3 Design, program & evaluate
- Write69%
- Complete33%
- Describe19%
- Explain19%
19.1Building ADTs from other ADTs#4 of 7 on Paper 4Occasional · 3328% next paper3.8 marks8/32 sittings↘ May/Jun 2026Occasional · 3328%
3.8 · 17% of topic8/32May/Jun 2026latest series · ↘Rotated in occasionally — the bullet students skip and then meet.Syllabus: stack, queue, linked list, dictionary and binary tree implementations; comparing algorithms with Big O time and space complexity
- Next Paper 4
- 28%
- 1 in 4
- Marks a paper
- 3.8
- 5% of the paper · 17% of the topic
- Asked in
- 8 / 32
- Paper 4 sittings · 34 questions
- Last asked
- May/Jun 2026
- 9618/43 · Q3 · 14 marks
- Asked in 8 of 32 Paper 4 sittings — roughly one paper in 4.
- About 3.8 marks a paper (5% of Paper 4; 17% of the topic's marks across its 3 bullets).
- Last asked May/Jun 2026 · 9618/43 · Q3 (14 marks) — in the most recent series.
- Easing: 4.6 → 4.1 marks a paper.
- Usually “Write” or “Complete”: you must produce something — code, a diagram, a table — practise doing it, not reading it.
- Biggest chunk of marks so far: 26 in May/Jun 2024 · 9618/42 · Q2.
- It is examined mostly as AO3 (Design, program & evaluate, 70%) — you must build it — write the pseudocode or program, design the structure.
Last 12 sittings↘ EasingAssessment objectives
AO1 17%AO3 70%- AO1 Knowledge & understanding
- AO2 Apply & analyse
- AO3 Design, program & evaluate
- Write59%
- Complete59%
- State29%
- Explain27%
19.2Recursion#5 of 7 on Paper 4Occasional · 2028% next paper1.5 marks8/32 sittings→ Oct/Nov 2025Occasional · 2028%
1.5 · 8% of topic8/32Oct/Nov 20251 series ago · →Rotated in occasionally — the bullet students skip and then meet.Syllabus: essential features; writing and tracing recursive algorithms; when recursion is beneficial; how a compiler uses the stack (winding and unwinding)
- Next Paper 4
- 28%
- 1 in 4
- Marks a paper
- 1.5
- 2% of the paper · 8% of the topic
- Asked in
- 8 / 32
- Paper 4 sittings · 19 questions
- Last asked
- Oct/Nov 2025
- 9618/43 · Q3 · 6 marks · 1 series ago
- Asked in 8 of 32 Paper 4 sittings — roughly one paper in 4.
- About 1.5 marks a paper (2% of Paper 4; 8% of the topic's marks across its 3 bullets).
- Last asked Oct/Nov 2025 · 9618/43 · Q3 (6 marks), 1 series ago.
- Usually “Write” or “Complete”: you must produce something — code, a diagram, a table — practise doing it, not reading it.
- Biggest chunk of marks so far: 14 in May/Jun 2024 · 9618/42 · Q3.
- It is examined mostly as AO3 (Design, program & evaluate, 54%), the rest AO1 (31%) — you must build it — write the pseudocode or program, design the structure.
Last 12 sittings→ SteadyAssessment objectives
AO1 31%AO2 15%AO3 54%- AO1 Knowledge & understanding
- AO2 Apply & analyse
- AO3 Design, program & evaluate
- Write58%
- Complete47%
- Explain26%
- Describe21%
19% of the topic's marks sit in question parts that belong to another topic (scenario questions cross sections) or that no bullet claims; they count for the topic, not for a bullet.
Marks a paper, year by year
By exam series
- May/Jun14/18 · 32.2 mk
- Oct/Nov14/14 · 25.9 mk
Across papers: Paper 3 100% of sittings, ~13.3 marks · Paper 4 88% of sittings, ~29.4 marks.
What you need to know3syllabus §19.1, §19.2
- 19.1Algorithms — linear and binary search (conditions, performance); insertion and bubble sort; finding, inserting and deleting items in stacks, queues, linked lists and binary trees; graphs as ADTs
- 19.1Building ADTs from other ADTs — stack, queue, linked list, dictionary and binary tree implementations; comparing algorithms with Big O time and space complexity
- 19.2Recursion — essential features; writing and tracing recursive algorithms; when recursion is beneficial; how a compiler uses the stack (winding and unwinding)
Video lectures33ZAK's YouTube channel · play here
A29618 Paper 320241.3K views
A22024522 views
ASA22024642 views
ASA22024293 views
ASA22024291 views
A22023422 views
Infographics5draw these the way the examiner expects · download as PNG
Binary search & insertion sort
Stack, queue & linked list
Recursion: winding & unwinding
Big O & algorithm performance
Binary tree & hash table
Key terms12use these exact words in the exam
Code help3referenced to the Cambridge pseudocode guide
FUNCTION Factorial(N : INTEGER) RETURNS INTEGERIF N <= 1 THENRETURN 1ENDIFRETURN N * Factorial(N - 1)ENDFUNCTIONFUNCTION SumDigits(N : INTEGER) RETURNS INTEGERIF N < 10 THENRETURN NENDIFRETURN (N MOD 10) + SumDigits(N DIV 10)ENDFUNCTIONFUNCTION Fib(N : INTEGER) RETURNS INTEGERIF N <= 2 THENRETURN 1ENDIFRETURN Fib(N - 1) + Fib(N - 2)ENDFUNCTIONOUTPUT Factorial(5), " ", SumDigits(345), " ", Fib(10)
DECLARE A : ARRAY[1:8] OF INTEGERDECLARE i : INTEGERFOR i ← 1 TO 8A[i] ← i * iNEXT iFUNCTION BSearch(Target : INTEGER, Low : INTEGER, High : INTEGER) RETURNS INTEGERDECLARE Mid : INTEGERIF Low > High THENRETURN -1ENDIFMid ← (Low + High) DIV 2IF A[Mid] = Target THENRETURN MidENDIFIF A[Mid] < Target THENRETURN BSearch(Target, Mid + 1, High)ENDIFRETURN BSearch(Target, Low, Mid - 1)ENDFUNCTIONOUTPUT "49 is at index ", BSearch(49, 1, 8)
DECLARE Val, L, R : ARRAY[1:10] OF INTEGERDECLARE Root, Free, i : INTEGERRoot ← 0Free ← 1FOR i ← 1 TO 10L[i] ← 0R[i] ← 0NEXT iPROCEDURE Insert(V : INTEGER)DECLARE P : INTEGERVal[Free] ← VIF Root = 0 THENRoot ← FreeELSEP ← RootREPEATIF V < Val[P] THENIF L[P] = 0 THENL[P] ← FreeP ← 0ELSEP ← L[P]ENDIFELSEIF R[P] = 0 THENR[P] ← FreeP ← 0ELSEP ← R[P]ENDIFENDIFUNTIL P = 0ENDIFFree ← Free + 1ENDPROCEDUREPROCEDURE InOrder(P : INTEGER)IF P <> 0 THENCALL InOrder(L[P])OUTPUT Val[P]CALL InOrder(R[P])ENDIFENDPROCEDURECALL Insert(50)CALL Insert(30)CALL Insert(70)CALL Insert(20)CALL Insert(40)CALL InOrder(Root)
Playground examples33runnable programs for this topic
- Run
Binary search (iterative)
Only works on sorted data: halve the search range each time by comparing with the middle element.
ASA2PseudocodeSearching 9618 §19.1 - Run
Binary search (recursive)
Two base cases — empty range (not found) and middle matches (found) — and two recursive calls.
A2PseudocodeSearching 9618 §19.1 - Run
Linear vs binary search — count the comparisons
Big O in practice: 1000 sorted items, linear search is O(n) and binary search O(log n).
A2PseudocodeSearching 9618 §19.1 - Run
Bubble sort with a Swapped flag
Stop early when a whole pass makes no swaps — the efficient version examiners like.
ASA2PseudocodeSorting 9618 §9.2, §19.1 - Run
Insertion sort
Take each value in turn and slide it left into the sorted part of the array.
ASA2PseudocodeSorting 9618 §19.1 - Run
Stack — push, pop, overflow & underflow
LIFO with an array and a Top pointer. Watch what happens on the 4th pop.
ASA2PseudocodeStacks, queues, lists & trees 9618 §10.4, §19.1 - Run
Linear queue — enqueue & dequeue
FIFO with Front and Rear pointers. Notice the space at the front is never reused.
ASA2PseudocodeStacks, queues, lists & trees 9618 §10.4, §19.1 - Run
Circular queue
Rear MOD Size + 1 wraps the pointer back to slot 1 so freed space is reused.
A2PseudocodeStacks, queues, lists & trees 9618 §19.1 - Run
Linked list in arrays with a free list
Insert at the front, delete by value, traverse — using Data/Pointer records, StartPointer and FreePointer.
ASA2PseudocodeStacks, queues, lists & trees 9618 §10.4, §19.1 - Run
Binary search tree — insert, search & three traversals
Nodes in an array with LeftPointer/RightPointer; in-order traversal outputs the values sorted.
A2PseudocodeStacks, queues, lists & trees 9618 §19.1 - Run
Hash table with linear probing
Key MOD TableSize gives the slot; on a collision, step to the next free slot.
A2PseudocodeStacks, queues, lists & trees 9618 §19.1 - Run
Dictionary — key → value pairs
A dictionary ADT built from an array of records: Add updates an existing key or appends a new one; Lookup returns the value.
A2PseudocodeStacks, queues, lists & trees 9618 §19.1 - Run
Using a stack — balanced brackets
Push every ( and pop on every ); the expression is balanced if the stack ends empty and never underflows.
A2PseudocodeStacks, queues, lists & trees 9618 §19.1 - Run
Evaluate Reverse Polish Notation with a stack
Operands are pushed; an operator pops two, applies itself and pushes the result — how a compiler evaluates RPN.
A2PseudocodeStacks, queues, lists & trees 9618 §16.3 - Run
Factorial — the first recursive function
Base case N <= 1 returns 1; the general case calls itself with N - 1.
A2PseudocodeRecursion 9618 §19.2 - Run
Winding and unwinding — watch the call stack
Output before the recursive call happens on the way down; output after it happens on the way back up.
A2PseudocodeRecursion 9618 §19.2 - Run
Fibonacci numbers
Two base cases and two recursive calls — simple to write, expensive to run.
A2PseudocodeRecursion 9618 §19.2 - Run
Recursive power & digit sum
Two more classic recursive definitions: x^n = x * x^(n-1), and digit sum = last digit + digit sum of the rest.
A2PseudocodeRecursion 9618 §19.2 - Run
Greatest common divisor (Euclid)
GCD(A, B) = GCD(B, A MOD B) until B is 0.
A2PseudocodeRecursion 9618 §19.2 - Run
Tower of Hanoi
Move N-1 discs out of the way, move the biggest, move the N-1 back. 2^N - 1 moves.
A2PseudocodeRecursion 9618 §19.2 - Run
Recursion vs iteration
The same sum written both ways — same answer, different use of the stack.
A2PseudocodeRecursion 9618 §19.2 - Run
Reverse a string recursively
Reverse of S = reverse of everything after the first character, followed by the first character.
A2PseudocodeRecursion 9618 §19.2 - Run
A Stack class
The stack ADT wrapped in a class: the array and Top are PRIVATE, so only Push/Pop can touch them.
A2PseudocodeObject-oriented programming §10.1 · 9618 §19.1 - Run
Frequency count with a list and a dictionary
Count dice rolls two ways: a list indexed by value, and a dictionary (the ADT the exam calls a dictionary).
ASA2PythonArrays §3 ↔ Python - Run
Binary search — iterative and recursive
Halve the search space each time; the list must be sorted. Both versions, with the number of comparisons.
ASA2PythonSearching §7 ↔ Python - Run
Insertion sort
Take each item and slide it left into the sorted part. Compare with sorted() and .sort() at the end.
ASA2PythonSorting §7 ↔ Python - Run
Stack and queue with a list
append/pop give a stack; append/pop(0) a queue. Watch the order things come out.
ASA2PythonStacks, queues, lists & trees §10 ADT ↔ Python - Run
Stack as a class with an array and a pointer
The exam implementation: fixed-size list, top pointer, isFull / isEmpty checks — not just list.pop().
A2PythonStacks, queues, lists & trees 9618 §19.1 ↔ Python - Run
Linked list with nodes and pointers
Node objects linked by a next reference; insert at the front, traverse, delete a value.
A2PythonStacks, queues, lists & trees 9618 §19.1 ↔ Python - Run
Binary search tree — insert and in-order traversal
Recursive insert and traversal on a tree of nodes. In-order gives the values sorted.
A2PythonStacks, queues, lists & trees 9618 §19.1 ↔ Python - Run
Hash table with linear probing
A hash function (key mod size) and collision handling by probing — the §19.1 implementation, before using dict.
A2PythonStacks, queues, lists & trees 9618 §19.1 ↔ Python - Run
Recursion — factorial, Fibonacci, GCD
Base case + general case. Open the Trace tab to see n shrink as the calls wind in.
A2PythonRecursion 9618 §19.2 ↔ Python - Run
Towers of Hanoi
The classic recursive puzzle: move n-1 discs aside, move the last, move the n-1 back.
A2PythonRecursion 9618 §19.2 ↔ Python
Declarative Lab4Prolog knowledge bases with sample queries
- Run
ancestor/2 — the classic recursive rule
Base case: a parent is an ancestor. Recursive case: a parent of an ancestor is an ancestor. Order of the clauses matters.
A2Recursive rules 9618 §20.1 - Run
Lists — [Head | Tail]
A list is a head and a tail. Unification splits it: [H|T] = [a, b, c] gives H = a, T = [b, c].
A2Lists 9618 §20.1 - Run
Recursing over a list — length, sum, count
Base case on [], recursive case on [H|T]. Note that the arithmetic comes AFTER the recursive call so N1 has a value.
A2Lists 9618 §20.1 - Run
Factorial and Fibonacci
Recursion with arithmetic. The guard N > 0 stops the recursion running below zero.
A2Arithmetic 9618 §20.1
Data Structures Playground16operation scripts on stacks, queues, linked lists, trees and hash tables — stepped through with the pseudocode
- Open
Push, push, pop
The first stack question: three pushes, two pops, what is left and where is TopPointer?
ASA2Stacks 9618 §10.4 - Open
Stack overflow and underflow
A stack of 3: the fourth push is refused; popping past empty is refused too.
ASA2Stacks 9618 §10.4 - Open
Stack as a bracket checker
Push every opening bracket, pop on every closing one — the stack is empty at the end only if the brackets match.
A2Stacks 9618 §19.1 - Open
Linear queue fills up
Why a linear queue is wasteful: after dequeuing, the space at the front cannot be reused.
ASA2Queues 9618 §10.4 - Open
Circular queue wrap-around
The same operations on a circular queue: RearPointer wraps to 1 and Ed fits.
ASA2Queues 9618 §10.4 - Open
Print queue
Jobs arrive and are printed in order — FIFO in action.
ASQueues 9618 §10.4 - Open
Insert into an ordered linked list
Values arrive out of order; each takes the next free node and is linked in order — watch StartPointer and FreePointer.
ASA2Linked lists 9618 §10.4 - Open
Delete from a linked list
Deleting relinks the previous node and returns the node to the free list — the data may still be visible in the array.
A2Linked lists 9618 §19.1 - Open
Search a linked list
Follow the pointers from StartPointer until the value or pointer 0.
A2Linked lists 9618 §19.1 - Open
Build a binary search tree
Insert 50, 30, 70, 20, 40, 60, 80 — smaller to the left, larger to the right — and read off the arrays.
A2Binary trees 9618 §19.1 - Open
In-order, pre-order, post-order
The same tree, three traversals — in-order gives sorted output; the others are the exam's favourite trick.
A2Binary trees 9618 §19.1 - Open
Tree of words
Strings compare alphabetically — insert names and search for one.
A2Binary trees 9618 §19.1 - Open
Sorted input makes a bad tree
Inserting 1, 2, 3, 4, 5 in order gives a tree that is really a list — every FIND walks the whole thing.
A2Binary trees 9618 §19.1 - Open
Hash table with MOD 10
Keys hashed with key MOD 10; 23 and 13 collide, so 13 is probed to the next free slot.
A2Dictionaries / hash tables 9618 §19.1 - Open
Hashing words by ASCII sum
A string key is turned into a number (sum of ASCII codes) before MOD — see the working for each key.
A2Dictionaries / hash tables 9618 §19.1 - Open
Delete leaves a tombstone
Deleting a key that another key was probed past must not break later lookups.
A2Dictionaries / hash tables 9618 §19.1
OOP Designer1class diagrams with the skeleton code in four languages
- Open
Read: a Stack class
A class that wraps an array and TopPointer — the ADT as an object.
A2Read the code → draw the diagram 9618 §20.1
Test yourself
Ready to check you know it?
Every round is a fresh random draw, weak cards come back until you get them right, and past-paper questions come with their mark schemes. Marks earn XP on your dashboard.