OCR H446 A Level Computer Science · 2.1 and 2.2 Computational Thinking and Problem Solving
Stretch tasks Programming Techniques and Computational Methods
Quiz Challenge
A quiz game against four computer players, then short and long written answers.
- Quiz Blitz12 questions against the clock
- Quick Fire4 short answers
- Big Think2 long answers
About 20 minutes
This or That
Pixel the cat asks 8 questions. Each has two answers: pick the right one.
- Two answers to every question
- A fish treat for every right answer
- Streaks win Pixel shades, then a party hat
About 4 minutes
Memory Match
Flip the cards two at a time to match each term card to its meaning card.
- 12 cards: each term has a meaning
- One peek at every card
- Combo points for pairs found in a row
6 pairs, about 4 minutes
Sort It
Sort each statement into the right box, like the tick box tables in the exam.
- 12 cards to sort into 4 boxes
- Drag a card, tap a box or press its number
- Combo points for cards sorted in a row
12 cards, about 4 minutes
Code Word
Guess the lesson's secret words. Every guess shows which letters are right.
- A clue for every word
- Tiles turn green, amber or grey after each guess
- Fewer guesses win more points
3 words, about 4 minutes
Link Up
12 tiles hide 3 groups of 4. Work out what links them.
- Pick four tiles that belong together
- Four slips and the round is over
- Fewer slips win more points
3 groups, about 3 minutes
Bug Hunt
Two statements are true and one has a bug. Catch the bug before it gets away.
- Three statements in every round
- Tap the one with the mistake
- Streaks win bonus points
5 rounds, about 4 minutes
Brain games
Train your brain on this lesson
Logic, memory and speed, built from this lesson's own key ideas. Win up to three diamonds in each game.
Odd One Out
Four tiles: three share a link and one does not. Spot the odd one out, then see what links the rest.
- Three belong together, one does not
- A hint shows the link, for fewer points
- Quick answers and streaks win more
8 rounds, about 3 minutes
Memory Flash
Study the term cards, then they flip over. Find the card that goes with each clue, from memory.
- Three levels: 3, 4 and 6 cards
- Two tries to find each card
- Streaks win bonus points
3 levels, about 4 minutes
Fact or Fib
Statements fly in one at a time. Is each one a fact or a fib? Decide fast.
- Swipe, tap or use the arrow keys
- Every fib comes with its fix
- Streaks multiply your points
12 statements, about 3 minutes
The final challenge
City Run
Race a robot cat on inline skates through a neon cyber city, from Neon Station to the Hyper Tunnel. Every question is a row of neon gates across the tracks: skate through the one with the right answer, dodge the trains and barriers, and grab diamonds.
- 20 questions from this lesson, in four parts of the city
- Swipe, tap or use the arrow keys
- Dodge trains and holograms, and jump crates and cones
20 questions, about 6 minutes
Bonus challenge
Neon Roll
Roll a glowing ball down an endless neon slope, past towers lit up with neon signs of Pixel the cat. Steer, jump the gaps and dodge the blocks. Questions from this lesson wait at gates along the way: every right answer keeps the ball rolling.
- Questions from this lesson at every gate
- Hold the arrow keys or a side of the slope to steer
- 8 right answers win two diamonds, 15 win three
Endless, about 5 minutes
The games need JavaScript. Every question is below, with the answers at the end.
Read the lesson: Programming Techniques and Computational Methods
Programming Techniques and Computational Methods: the questions
Quiz Challenge, round 1: Quiz Blitz
What stops a recursive subroutine calling itself forever?
- A global variable
- A loop counter
- A second parameter
- A base case
What does this function return for factorial(4)?
def factorial(n): if n <= 1: return 1 return n * factorial(n - 1)- 10
- 16
- 4
- 24
Every recursive algorithm can also be written iteratively.
- True
- False
What happens to memory each time a recursive call is made?
- Nothing, recursion uses no memory
- The program counter is reset
- A new stack frame is added
- The heap is cleared
Which TWO are true of passing by reference?
Tick 2.
- A copy of the value is passed
- The original is always protected
- It always uses more memory
- The subroutine can change the original
- The address is passed
Put the steps of backtracking in order.
Number these 1 to 4.
- Find it does not lead to a solution
- Return to the last decision point
- Try a different option
- Follow a path
Which IDE feature pauses a program at a chosen line?
- A breakpoint
- Syntax highlighting
- Auto complete
- Version control
A heuristic always finds the best possible answer.
- True
- False
What error occurs when recursion goes so deep that the stack runs out?
Which method splits a problem into smaller copies of itself and combines the results?
- Backtracking
- Data mining
- Visualisation
- Divide and conquer
Why are global variables discouraged?
- They can be changed from anywhere, so faults are hard to trace
- They use no memory
- They cannot hold strings
- They disappear when a subroutine ends
Which computational method looks for unknown patterns in huge datasets?
- Backtracking
- Performance modelling
- Data mining
- Pipelining
Quiz Challenge, round 2: Quick Fire
Explain the difference between passing a parameter by value and by reference. [2 marks]
Compare recursion with iteration in terms of memory. [2 marks]
Explain why a satnav uses a heuristic rather than checking every possible route. [2 marks]
Explain how backtracking solves a maze. [2 marks]
Quiz Challenge, round 3: Big Think
Compare recursion and iteration, using factorial as an example. [6 marks]
Explain how divide and conquer makes merge sort faster than bubble sort on large lists. [4 marks]
This or That: tick the right answer
Which uses more memory as it goes deeper?
- Recursion
- Iteration
A subroutine changes its parameter and the caller's variable changes too. How was it passed?
- By value
- By reference
Which is usually faster to run?
- Iteration
- Recursion
Which solves a sudoku by undoing wrong guesses?
- Backtracking
- Data mining
Which variable exists only while its subroutine runs?
- A local variable
- A global variable
A bank simulates a million customers before switching on a new system. What is this?
- Performance modelling
- Visualisation
Which helps people spot patterns in ten thousand rows of data?
- Visualisation
- Pipelining
Which IDE feature shows a variable's value as the code runs?
- Auto complete
- A watch
Memory Match: match each term to its meaning
| Term | Meaning |
|---|---|
| A Base case | 1 A rule of thumb for a good enough answer |
| B Stack frame | 2 Returns without making another call |
| C Scope | 3 Return to the last choice and try another |
| D Heuristic | 4 Pauses the program at a chosen line |
| E Backtracking | 5 Where an identifier can be used |
| F Breakpoint | 6 Parameters, locals and the return address |
Sort It: tick one box in each row
Which computational method does each example use?
| Statement | Divide and conquer | Backtracking | Heuristics | Data mining |
|---|---|---|---|---|
| A satnav picking a good route quickly | ||||
| A good enough timetable found fast | ||||
| Finding patterns in millions of loyalty card records | ||||
| A star using straight line distance | ||||
| Quicksort around a pivot | ||||
| Solving a maze by retreating from dead ends | ||||
| Filling a sudoku and undoing wrong guesses | ||||
| Spotting early signs a machine will fail | ||||
| Merge sort | ||||
| Finding products often bought together | ||||
| Binary search halving the list | ||||
| Placing eight queens on a chessboard |
Code Word: write the word that fits each clue
A subroutine calling itself, stopped by a base case. (9 letters)
Where in a program an identifier can be accessed. (5 letters)
A rule of thumb that gives a good enough answer quickly. (9 letters)
Link Up: find the three groups
These 12 tiles make 3 groups of 4. Write each group in the table, and what links its tiles.
- Stack frames
- Stepping
- Backtracking
- Calls to itself
- Data mining
- Base case
- General case
- Breakpoints
- Visualisation
- Auto complete
- Variable watch
- Heuristics
| Group | The 4 tiles | What links them |
|---|---|---|
| Group 1 | ||
| Group 2 | ||
| Group 3 |
Bug Hunt: tick the statement that is wrong
In each set, two statements are true and one has a mistake in it.
- Each recursive call adds a stack frame.
- A recursive subroutine needs a base case.
- Recursion uses less memory than the same loop.
- Passing by reference passes the address of the variable.
- Passing by value gives the subroutine a copy.
- A value parameter changes the original variable.
- A local variable exists only while its subroutine runs.
- Global variables make faults easier to trace.
- A global variable can be changed from anywhere.
- Backtracking returns to the last decision point when a path fails.
- Merge sort uses divide and conquer.
- Data mining finds the best route between two places.
- Stepping runs a program one line at a time.
- Performance modelling means building the real system and timing it.
- A breakpoint pauses a program at a chosen line.
Brain game: Odd One Out
Three tiles in each set share a link. Tick the odd one out, then write what links the other three.
- Backtracking
- Calls to itself
- Visualisation
- Heuristics
What links the other three?
- Stepping
- Breakpoints
- Auto complete
- Heuristics
What links the other three?
- Stack frames
- Base case
- General case
- Variable watch
What links the other three?
- Stack frames
- Backtracking
- Data mining
- Heuristics
What links the other three?
- Stepping
- Base case
- Breakpoints
- Auto complete
What links the other three?
- Stack frames
- Base case
- General case
- Visualisation
What links the other three?
Brain game: Memory Flash, on paper
Which term means this? Write your answer from memory.
A rule of thumb for a good enough answer
Returns without making another call
Return to the last choice and try another
Pauses the program at a chosen line
Where an identifier can be used
Parameters, locals and the return address
Brain game: Fact or Fib
Tick Fact if the statement is true and Fib if it is not.
Performance modelling means building the real system and timing it.
- Fact
- Fib
Data mining finds the best route between two places.
- Fact
- Fib
Passing by value gives the subroutine a copy.
- Fact
- Fib
Backtracking returns to the last decision point when a path fails.
- Fact
- Fib
A value parameter changes the original variable.
- Fact
- Fib
Recursion uses less memory than the same loop.
- Fact
- Fib
A heuristic always finds the best possible answer.
- Fact
- Fib
Global variables make faults easier to trace.
- Fact
- Fib
Passing by reference passes the address of the variable.
- Fact
- Fib
A local variable exists only while its subroutine runs.
- Fact
- Fib
Stepping runs a program one line at a time.
- Fact
- Fib
Each recursive call adds a stack frame.
- Fact
- Fib
City Run
City Run is a race through a neon cyber city, played on screen. It asks 20 of the questions above, from the quiz, This or That, Memory Flash and Fact or Fib.
Neon Roll
Neon Roll is a ball rolling down an endless neon slope, played on screen. Every right answer keeps it rolling. It asks the questions above, from the quiz, This or That, Memory Flash and Fact or Fib.
Answers
Round 1: Quiz Blitz
- A base case The base case returns without recursing, and every other call must move towards it.
- 24 4 times 3 times 2 times 1 is 24. The base case returns 1 when n reaches 1.
- True The choice is about which expresses the problem more clearly, and whether the stack can take the depth.
- A new stack frame is added Each frame holds the parameters, local variables and return address, so deep recursion can overflow the stack.
- The subroutine can change the original; The address is passed Passing by reference passes the address, so the subroutine works on the original. Passing a copy is passing by value.
- Follow a path → Find it does not lead to a solution → Return to the last decision point → Try a different option Backtracking explores, retreats to the last choice when it fails, and tries again.
- A breakpoint Once paused, you can step through the code and watch the variables change.
- False A heuristic finds a good enough answer quickly. It trades the guarantee of the best answer for speed.
- stack overflow Every call adds a stack frame, so very deep recursion uses up the stack.
- Divide and conquer Merge sort, quicksort and binary search all work this way.
- They can be changed from anywhere, so faults are hard to trace A subroutine that uses globals cannot be understood on its own.
- Data mining Finding products often bought together is a classic example.
Round 2: Quick Fire
- By value passes a copy, so the original is not changed
- By reference passes the address, so changes affect the original
Model answerPassing by value gives the subroutine a copy, so changes inside it do not affect the original. Passing by reference gives it the address, so changes inside it affect the original variable.
- Each recursive call adds a stack frame, so memory grows with depth
- Iteration uses a constant amount of memory
- Deep recursion can overflow the stack
Model answerEach recursive call adds a stack frame, so memory grows with the depth of recursion and can overflow the stack, while iteration uses a constant amount of memory.
- Checking every route would take far too long
- A heuristic gives a good enough route quickly, though not always the best
Model answerChecking every possible route would take far too long, so a heuristic finds a good enough route quickly, even though it is not guaranteed to be the best.
- It follows a path until it reaches a dead end
- Then it returns to the last decision point and tries another route
Model answerIt follows a path until it reaches a dead end, then goes back to the last decision point and tries a different route, repeating until it finds the exit.
Round 3: Big Think
- A recursive factorial calls itself
- A base case stops it, returning 1
- The general case moves towards the base case
- Each call adds a stack frame, so memory grows
- Deep recursion risks a stack overflow
- An iterative version uses a loop and constant memory
- Iteration is faster, with no call overhead
- Recursion is clearer for naturally recursive problems
Model answerA recursive factorial calls itself: the base case returns 1 when n is 1 or less, and the general case returns n times the factorial of n minus 1, which moves towards the base case. Each call adds a stack frame, so memory grows with n and a large n could cause a stack overflow. An iterative version uses a for loop that multiplies a running product, so it uses a constant amount of memory and is faster because there is no call overhead. Recursion is clearer for problems that are naturally recursive, such as tree traversal, but iteration suits simple repetition like this.
- The list is split in half repeatedly until each part holds one item
- The sorted parts are combined back together
- There are about log n levels of splitting
- Each level handles all n items, so it takes n log n time
- Bubble sort takes n squared time
Model answerMerge sort repeatedly splits the list in half until each part holds one item, then combines the sorted sub lists. There are about log n levels of splitting and each level handles all n items, so it takes n log n time. Bubble sort compares adjacent pairs pass after pass, which takes n squared time, so on a large list merge sort does far less work.
This or That
- Recursion Every recursive call adds a stack frame. A loop reuses the same variables.
- By reference Passing by reference gives the address, so the subroutine works on the original.
- Iteration Recursion pays for a stack frame on every call. A loop has no call overhead.
- Backtracking Backtracking returns to the last choice when a path fails and tries another.
- A local variable A local's scope and lifetime are limited to its subroutine. A global lasts for the whole program.
- Performance modelling Modelling predicts how the system behaves under load without risking the real thing.
- Visualisation A chart shows at a glance a pattern that a table would hide.
- A watch A variable watch lets you see a value change as you step through the code.
Memory Match
- A 2 Base case: Returns without making another call
- B 6 Stack frame: Parameters, locals and the return address
- C 5 Scope: Where an identifier can be used
- D 1 Heuristic: A rule of thumb for a good enough answer
- E 3 Backtracking: Return to the last choice and try another
- F 4 Breakpoint: Pauses the program at a chosen line
Sort It
- Heuristics A satnav picking a good route quickly A good enough route found fast is a heuristic result.
- Heuristics A good enough timetable found fast Accepting good enough to save time is the heuristic trade off.
- Data mining Finding patterns in millions of loyalty card records Mining huge datasets for relationships nobody knew about is data mining.
- Heuristics A star using straight line distance The straight line estimate is A star's heuristic.
- Divide and conquer Quicksort around a pivot Quicksort partitions, then sorts each part the same way.
- Backtracking Solving a maze by retreating from dead ends Going back to the last choice when a path fails is backtracking.
- Backtracking Filling a sudoku and undoing wrong guesses Undoing a guess and trying another is backtracking.
- Data mining Spotting early signs a machine will fail Finding warning patterns in large records is data mining.
- Divide and conquer Merge sort Merge sort splits the list, sorts the halves and combines them.
- Data mining Finding products often bought together Searching big data for unknown patterns is data mining.
- Divide and conquer Binary search halving the list Each step solves a smaller copy of the same problem.
- Backtracking Placing eight queens on a chessboard Queens are placed and moved back when a placement fails, a classic backtracking problem.
Code Word
- RECURSION A subroutine calling itself, stopped by a base case.
- SCOPE Where in a program an identifier can be accessed.
- HEURISTIC A rule of thumb that gives a good enough answer quickly.
Link Up
- Computational methods Backtracking; Data mining; Heuristics; Visualisation
- IDE features Breakpoints; Stepping; Variable watch; Auto complete
- Recursion needs Base case; General case; Stack frames; Calls to itself
Bug Hunt: the wrong statement, and why
- Recursion uses less memory than the same loop. Every call adds a stack frame, so recursion uses more memory than a loop.
- A value parameter changes the original variable. A value parameter is a copy, so the original is untouched. Only passing by reference changes the original.
- Global variables make faults easier to trace. A global can be changed from anywhere, so a fault could come from any part of the program.
- Data mining finds the best route between two places. That is a job for a heuristic search such as A star. Data mining finds unknown patterns in large datasets.
- Performance modelling means building the real system and timing it. Performance modelling simulates the system mathematically, which is cheaper and safer than building it first.
Odd One Out
- Calls to itself is the odd one out: it goes with Recursion needs. The other three: Computational methods.
- Heuristics is the odd one out: it goes with Computational methods. The other three: IDE features.
- Variable watch is the odd one out: it goes with IDE features. The other three: Recursion needs.
- Stack frames is the odd one out: it goes with Recursion needs. The other three: Computational methods.
- Base case is the odd one out: it goes with Recursion needs. The other three: IDE features.
- Visualisation is the odd one out: it goes with Computational methods. The other three: Recursion needs.
Memory Flash
- Heuristic A rule of thumb for a good enough answer
- Base case Returns without making another call
- Backtracking Return to the last choice and try another
- Breakpoint Pauses the program at a chosen line
- Scope Where an identifier can be used
- Stack frame Parameters, locals and the return address
Fact or Fib
- Fib Performance modelling means building the real system and timing it. The fix: Performance modelling simulates the system mathematically, which is cheaper and safer than building it first.
- Fib Data mining finds the best route between two places. The fix: That is a job for a heuristic search such as A star. Data mining finds unknown patterns in large datasets.
- Fact Passing by value gives the subroutine a copy.
- Fact Backtracking returns to the last decision point when a path fails.
- Fib A value parameter changes the original variable. The fix: A value parameter is a copy, so the original is untouched. Only passing by reference changes the original.
- Fib Recursion uses less memory than the same loop. The fix: Every call adds a stack frame, so recursion uses more memory than a loop.
- Fib A heuristic always finds the best possible answer. The fix: A heuristic finds a good enough answer quickly. It trades the guarantee of the best answer for speed.
- Fib Global variables make faults easier to trace. The fix: A global can be changed from anywhere, so a fault could come from any part of the program.
- Fact Passing by reference passes the address of the variable.
- Fact A local variable exists only while its subroutine runs.
- Fact Stepping runs a program one line at a time.
- Fact Each recursive call adds a stack frame.

