DoRevision

Algorithm Detective

Tracing is the working, not the answer. Fill the table, then say in one sentence what the algorithm is actually for, and learn the test that tells the two apart.

⏱️ 18 min 🎯 15 activities
Best used for
Independent study Intervention Mock preparation

Get the method right under pressure

Free interactive practice on the steps that lose marks under exam pressure.

Start revising free

What you'll cover

The question after the trace

You already know what sequence, selection and iteration are, and how a loop runs. This topic is not about that. It is about being handed an algorithm you have never seen and working out what it does. Most people learn to trace and stop there. Tracing is the working, not the answer. When a question says *what does this algorithm do*, it wants one sentence naming the job, and a line-by-line account of your trace scores badly no matter how correct the trace was. So this module runs in that order every time: fill the table, then name the job. And it gives you a test for telling the two apart, which is the single most useful thing here.

Ways an algorithm gets written down

Six terms. The last one is not a notation at all, and it is the one the marks hang on.

Three notations, three jobs

They are not interchangeable. Each one makes something easy to see and something else hard to see, and a question will usually have picked the one that suits it.

How to state what it does

There is an order to this and doing it in the wrong order is what costs marks. Finish the working first. Do not try to say what something does while you are still figuring out what it produces; you will end up describing the bit you have just done. Then look only at what came out, and at the values you ended with. Not at the lines. Say the result in one sentence, in terms of what somebody using it would get, rather than in terms of what the variables did on the way. ⚠️ Here is the test, and it is worth more than any other sentence in this module. Could somebody use your sentence to predict the output for a DIFFERENT input? If yes, you have given a purpose. If no, you have described one run, and describing one run is what a narration is. A weak answer walks through the passes. A strong answer names the job and stops.

Match each notation to what it shows

  • Structure diagram
  • Flowchart
  • Pseudocode
  • Trace table
  • how a problem breaks into parts, without saying what runs first
  • the path through the algorithm, with decisions drawn as branches
  • the steps in structured English, tied to no particular language
  • the value each variable holds on each pass, and what comes out

Fill the table, then read it

Work through the algorithm one line at a time and fill in every blank cell. Each row shows the values after that pass of the loop.

What that algorithm is for

You have just traced it. Which sentence states what the algorithm DOES, rather than what happened on the way through?

  • It adds up the whole numbers from 1 to 4 and outputs the total
  • It sets total to 0, then adds 1, then adds 2, then adds 3, then adds 4
  • It counts from 1 to 4
  • It outputs 10

True about tracing

Select the TWO statements that are true.

  • Columns are updated in the order the lines actually run, so each row shows the values after that pass
  • A trace table is a way of working out the output, not the answer to what the algorithm does
  • The purpose of an algorithm is best given as a line-by-line account of the trace
  • Tracing is only useful for algorithms you have seen before

Complete the algorithm reading paragraph

A diagram that breaks a problem into parts and sub-parts is a _____. Steps written in structured English and tied to no particular programming language are _____. The formal notation this specification expects, which is not supplied to you in the exam, is the _____. A table with one column per variable and one row per pass is a _____.

structure diagram pseudocode Exam Reference Language trace table flowchart a compiler an operating system a variable

Read it at speed

Five quick readings, three lives. This is the part the exam puts under time pressure.

Two answers to the same question

Here is a different algorithm. It sets best to zero, goes through a list of numbers one at a time, and whenever it meets a number larger than best it stores that number in best. At the end it outputs best. Suppose the list is 4, 7, 2. A weak answer to "what does this algorithm do": "It sets best to 0, then best becomes 4, then best becomes 7, then 2 is not bigger so nothing changes, and it outputs 7." Every word of that is true. It would still score badly, because it is the trace read aloud. A strong answer: "It finds and outputs the largest number in the list." ⚠️ Now apply the test and watch the difference appear. Hand somebody a different list, say 9, 1, 5. The strong answer still works - they can tell you the output is 9 without seeing your trace. The weak answer is simply wrong now, because it was about one run and not about the algorithm. ⚠️ That is the whole discrimination, and it is worth checking your sentence against it before you write it down: if your answer stops being true when the input changes, it was never a purpose.

A second table, a harder purpose

Trace the algorithm from the card you have just read. Fill in the value of best after each pass, and the value that is output at the end.

Spot the true algorithm reading facts

Tap the TWO statements that are true.

  • A trace table records the value each variable holds on each pass
  • A structure diagram shows how a problem breaks into parts rather than the order things run
  • The Exam Reference Language is supplied on a sheet with the exam paper
  • Stating an algorithm's purpose means narrating each pass of the trace

Three algorithm calls

Three situations in the exam. Choose the response you could defend.

  • A student traces an algorithm perfectly, then answers the question "what does this algorithm do" with four sentences describing what happened on each pass. What is wrong?
  • A question hands you an algorithm you have never seen and asks what it outputs. What do you do first?
  • A Section B question says "Write an algorithm to..." on this paper. How must you answer it?

Explain how to read an unfamiliar algorithm

A friend can trace an algorithm accurately but keeps losing marks on the question that follows. Write them the advice.

  • Name three ways an algorithm can be written down and say what each one shows
  • Explain what a trace table is and the order you fill one in
  • Explain what a question is actually asking for when it says what does this algorithm do
  • Give the test for whether a sentence states a purpose rather than narrating one run
  • Finish with what this specification requires on a Section B Write question, and why it catches people out