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.
Statometer90BankerNext Paper 490%Everything for this topic — study hub
A2 Level · 9618 · Paper 4
This topic is rows 15–17 of the study route.Open it on your study route
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
- 90%
- 9 in 10 chance it is set
- Marks a paper
- 43.2 / 75
- 57% of Paper 4 · fair share 50%
- Appeared in
- 30 / 32
- Paper 4 sittings 2021–2026
- Last set
- May/Jun 2026
- 9618/43 · Q3 · 25 marks · 11-series streak
What the papers say
- Set in 30 of 32 Paper 4 sittings on the current syllabus — treat it as certain.
- Worth about 43.2 marks a paper (57% of Paper 4).
- Also turns up in Paper 3 (97% of sittings, ~10.1 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 11 series without a miss.
- Easing off: about 53 marks a paper earlier, 42.6 in the latest years — still examined, just smaller.
- Lives on “Write” and “Complete” — 92% of its questions: you must produce something — code, a diagram, a table — practise doing it, not reading it.
- 34% of its questions involve a diagram, table or figure — practise with pen and paper.
- 85% of its questions are set out as code, pseudocode or a table to complete.
- Most of its marks (85%) come in extended questions of 12+ marks — plan the answer before writing.
- Its biggest question so far: 31 marks (May/Jun 2024 · 9618/41 · Q2).
- Inside the topic, §19.1 Algorithms carries the most marks (65%) and §19.2 Recursion the least (10%).
- It is examined almost entirely as AO3 (Design, program & evaluate, 78%) — you must build it — write the pseudocode or program, design the structure.
- The examiner has commented on 124 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 mk20
- 7–9 mk31
- 10–12 mk25
- 13–15 mk25
- 16+ mk84
Average 18.1 marks a question · 34% with a figure or table · 85% with code · biggest 31 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 · 9690% next paper26.1 marks30/32 sittings↘ May/Jun 2026Banker · 9690%
26.1 · 65% of topic30/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
- 90%
- 9 in 10
- Marks a paper
- 26.1
- 35% of the paper · 65% of the topic
- Asked in
- 30 / 32
- Paper 4 sittings · 153 questions
- Last asked
- May/Jun 2026
- 9618/43 · Q3 · 6 marks · 11-series streak
- Asked in 30 of 32 Paper 4 sittings — nearly every paper.
- About 26.1 marks a paper (35% of Paper 4; 65% 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 11 series.
- Easing: 29.1 → 26 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, 75%) — you must build it — write the pseudocode or program, design the structure.
Last 12 sittings↘ EasingAssessment objectives
AO2 18%AO3 75%- AO1 Knowledge & understanding
- AO2 Apply & analyse
- AO3 Design, program & evaluate
- Write63%
- Complete49%
- State24%
- Explain21%
19.1Building ADTs from other ADTs#4 of 7 on Paper 4Core · 6048% next paper7 marks17/32 sittings→ May/Jun 2026Core · 6048%
7 · 26% of topic17/32May/Jun 2026latest series · →A regular earner inside the topic — most papers touch it.Syllabus: stack, queue, linked list, dictionary and binary tree implementations; comparing algorithms with Big O time and space complexity
- Next Paper 4
- 48%
- 2 in 4
- Marks a paper
- 7
- 9% of the paper · 26% of the topic
- Asked in
- 17 / 32
- Paper 4 sittings · 69 questions
- Last asked
- May/Jun 2026
- 9618/43 · Q3 · 14 marks · 3-series streak
- Asked in 17 of 32 Paper 4 sittings — about 5 papers in 10.
- About 7 marks a paper (9% of Paper 4; 26% of the topic's marks across its 3 bullets).
- Last asked May/Jun 2026 · 9618/43 · Q3 (14 marks) — in the most recent series.
- 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: 30 in May/Jun 2024 · 9618/41 · Q2.
- It is examined almost entirely as AO3 (Design, program & evaluate, 81%) — you must build it — write the pseudocode or program, design the structure.
Last 12 sittings→ SteadyAssessment objectives
AO3 81%- AO1 Knowledge & understanding
- AO2 Apply & analyse
- AO3 Design, program & evaluate
- Write67%
- Complete64%
- State32%
- Explain26%
19.2Recursion#5 of 7 on Paper 4Occasional · 2530% next paper2.3 marks10/32 sittings↘ Oct/Nov 2025Occasional · 2530%
2.3 · 10% of topic10/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
- 30%
- 1 in 4
- Marks a paper
- 2.3
- 3% of the paper · 10% of the topic
- Asked in
- 10 / 32
- Paper 4 sittings · 38 questions
- Last asked
- Oct/Nov 2025
- 9618/43 · Q3 · 6 marks · 1 series ago
- Asked in 10 of 32 Paper 4 sittings — roughly one paper in 3.
- About 2.3 marks a paper (3% of Paper 4; 10% of the topic's marks across its 3 bullets).
- Last asked Oct/Nov 2025 · 9618/43 · Q3 (6 marks), 1 series ago.
- Easing: 4.8 → 1.3 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: 17 in Oct/Nov 2021 · 9618/41 · Q1.
- It is examined mostly as AO3 (Design, program & evaluate, 68%), the rest AO1 (23%) — you must build it — write the pseudocode or program, design the structure.
Last 12 sittings↘ EasingAssessment objectives
AO1 23%AO3 68%- AO1 Knowledge & understanding
- AO2 Apply & analyse
- AO3 Design, program & evaluate
- Write50%
- Complete45%
- State34%
- Rewrite26%
26% 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
Grey years are the previous syllabus (2015–2021, 94 questions) — history, not counted in the rates.
By exam series
- May/Jun16/18 · 46 mk
- Oct/Nov14/14 · 48.6 mk
Across papers: Paper 3 97% of sittings, ~10.1 marks · Paper 4 94% of sittings, ~43.2 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
A22024614 views
ASA22024677 views
ASA22024296 views
ASA22024293 views
A22023442 views
A22023251 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
Dotted terms are defined in the glossary.
Code help4referenced 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)
DECLARE Queue : ARRAY[0:4] OF STRINGDECLARE Front, Rear, Size : INTEGERDECLARE Item : STRINGFront ← 0Rear ← -1Size ← 0PROCEDURE Enqueue(NewItem : STRING)IF Size = 5 THENOUTPUT "Queue full"ELSERear ← (Rear + 1) MOD 5Queue[Rear] ← NewItemSize ← Size + 1ENDIFENDPROCEDUREFUNCTION Dequeue() RETURNS STRINGDECLARE Out : STRINGIF Size = 0 THENRETURN ""ENDIFOut ← Queue[Front]Front ← (Front + 1) MOD 5Size ← Size - 1RETURN OutENDFUNCTIONCALL Enqueue("Job1")CALL Enqueue("Job2")CALL Enqueue("Job3")Item ← Dequeue()OUTPUT "Served ", ItemCALL Enqueue("Job4")Item ← Dequeue()OUTPUT "Served ", ItemOUTPUT Size, " jobs still waiting"
💡 MOD 5 makes the pointers wrap round, so the array is used as a circular queue.
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.
- Run
Binary search (recursive)
Two base cases — empty range (not found) and middle matches (found) — and two recursive calls.
- 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).
- Run
Bubble sort with a Swapped flag
Stop early when a whole pass makes no swaps — the efficient version examiners like.
- Run
Insertion sort
Take each value in turn and slide it left into the sorted part of the array.
- Run
Stack — push, pop, overflow & underflow
LIFO with an array and a Top pointer. Watch what happens on the 4th pop.
- Run
Linear queue — enqueue & dequeue
FIFO with Front and Rear pointers. Notice the space at the front is never reused.
- Run
Circular queue
Rear MOD Size + 1 wraps the pointer back to slot 1 so freed space is reused.
- Run
Linked list in arrays with a free list
Insert at the front, delete by value, traverse — using Data/Pointer records, StartPointer and FreePointer.
- Run
Binary search tree — insert, search & three traversals
Nodes in an array with LeftPointer/RightPointer; in-order traversal outputs the values sorted.
- Run
Hash table with linear probing
Key MOD TableSize gives the slot; on a collision, step to the next free slot.
- 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.
- Run
Using a stack — balanced brackets
Push every ( and pop on every ); the expression is balanced if the stack ends empty and never underflows.
- 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.
- Run
Factorial — the first recursive function
Base case N <= 1 returns 1; the general case calls itself with N - 1.
- 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.
- Run
Fibonacci numbers
Two base cases and two recursive calls — simple to write, expensive to run.
- 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.
- Run
Greatest common divisor (Euclid)
GCD(A, B) = GCD(B, A MOD B) until B is 0.
- Run
Tower of Hanoi
Move N-1 discs out of the way, move the biggest, move the N-1 back. 2^N - 1 moves.
- Run
Recursion vs iteration
The same sum written both ways — same answer, different use of the stack.
- Run
Reverse a string recursively
Reverse of S = reverse of everything after the first character, followed by the first character.
- Run
A Stack class
The stack ADT wrapped in a class: the array and Top are PRIVATE, so only Push/Pop can touch them.
- 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).
- Run
Binary search — iterative and recursive
Halve the search space each time; the list must be sorted. Both versions, with the number of comparisons.
- Run
Insertion sort
Take each item and slide it left into the sorted part. Compare with sorted() and .sort() at the end.
- Run
Stack and queue with a list
append/pop give a stack; append/pop(0) a queue. Watch the order things come out.
- 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().
- Run
Linked list with nodes and pointers
Node objects linked by a next reference; insert at the front, traverse, delete a value.
- Run
Binary search tree — insert and in-order traversal
Recursive insert and traversal on a tree of nodes. In-order gives the values sorted.
- Run
Hash table with linear probing
A hash function (key mod size) and collision handling by probing — the §19.1 implementation, before using dict.
- Run
Recursion — factorial, Fibonacci, GCD
Base case + general case. Open the Trace tab to see n shrink as the calls wind in.
- Run
Towers of Hanoi
The classic recursive puzzle: move n-1 discs aside, move the last, move the n-1 back.
Also for this topic: 11 Java programs · 10 VB.NET programs in the browser compilers.
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.
- 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].
- 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.
- Run
Factorial and Fibonacci
Recursion with arithmetic. The guard N > 0 stops the recursion running below zero.
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?
- Open
Stack overflow and underflow
A stack of 3: the fourth push is refused; popping past empty is refused too.
- 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.
- Open
Linear queue fills up
Why a linear queue is wasteful: after dequeuing, the space at the front cannot be reused.
- Open
Circular queue wrap-around
The same operations on a circular queue: RearPointer wraps to 1 and Ed fits.
- Open
Print queue
Jobs arrive and are printed in order — FIFO in action.
- 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.
- 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.
- Open
Search a linked list
Follow the pointers from StartPointer until the value or pointer 0.
- 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.
- 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.
- Open
Tree of words
Strings compare alphabetically — insert names and search for one.
- 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.
- 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.
- 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.
- Open
Delete leaves a tombstone
Deleting a key that another key was probed past must not break later lookups.
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.
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.
NewCS Games · 16 to play
Revise this topic by playing
Quiz battles, a daily CS word, SQL whodunnits, logic-gate puzzles and arcade — every game drills the syllabus. Solo against AskZ bots, with friends, or with your whole class. Free, no sign-up.


