Augment Education
    • Question bank
    • Quick fire
    • Worksheets
    • Flashcards
    • Notes
    • Try a quick-fire round
    • All features
    • Business
    • Digital Society
    • Economics
    • Geography
    • Global Politics
    • History
    • Philosophy
    • Psychology
    • Anthropology
    • World Religions
    • Biology
    • Chemistry
    • Physics
    • Computer Science
    • Design Technology
    • ESS
    • SEHS
    • Language and literature
    • Language acquisition
    • Maths AA
    • Maths AI
    • Dance
    • Film
    • Music
    • Theatre
    • Visual Arts
    • Grade calculator
    • Grade boundaries
    • Subject checker
    • Focus timer
    • Exam countdown
    • All free tools
    • IB guide
    • All subjects
  • Blog

Search

Search subjects, the syllabus, glossary terms, the booklets, the IB guide, help and the blog

Log inStart free
augment

Augment Education

IB Diploma revision built around the syllabus.

contact@augment-education.com

Product

  • Features
  • Question bank
  • Quick fire
  • Worksheets
  • Flashcards
  • Notes
  • Subjects
  • What's new

Learn

  • IB guide
  • Booklets, explained
  • Glossary
  • Blog
  • Free tools
  • Grade calculator
  • Subject checker

Company

  • About
  • Help
  • For parents
  • For teachers
  • Comparisons

Subjects

  • English A Lit
  • English A Lang & Lit
  • Chinese A Lit
  • Chinese A Lang & Lit
  • Spanish A Lit
  • Spanish A Lang & Lit
  • English Lit & Perf
  • Spanish Lit & Perf
  • English B
  • Mandarin B
  • Spanish B
  • English ab initio
  • Mandarin ab initio
  • Spanish ab initio
  • Business
  • Digital Society
  • Economics
  • Geography
  • Global Politics
  • History
  • Philosophy
  • Psychology
  • Anthropology
  • World Religions
  • Biology
  • Chemistry
  • Physics
  • Computer Science
  • Design Technology
  • ESS
  • SEHS
  • Maths AA
  • Maths AI
  • Dance
  • Film
  • Music
  • Theatre
  • Visual Arts

Augment Education is developed independently of the International Baccalaureate Organization and is not endorsed by it. “IB” and “International Baccalaureate” are its trademarks.

© 2026 Augment Education. All rights reserved.

  • Privacy
  • Terms
  1. Subjects
  2. Computer Science
  3. The algorithmic thinking question

The algorithmic thinking question

Answer Paper 2's no-code question by working small cases, writing precise numbered steps, tracing flowcharts with trace tables and reasoning about efficiency without code.

  • IB Computer Science
  • Exam skills
  • SL and HL

17 min readLast reviewed 14 Oct 2026

A question with no code

Paper 2 contains one compulsory question that focuses on algorithmic thinking without any code to read or write. It appears on the SL paper and is one of the two SL questions repeated on the HL paper, so every student answers it. The question tests whether you can design, follow and improve an algorithm without the support of a programming language, so it asks the same of you whether you studied Python or Java.

The guide says only that the question focuses on algorithmic thinking "without the need to interpret or write code". No 2027 paper is public yet, so the shapes described here are inferred from how the course frames algorithmic thinking and from earlier IB Computer Science papers. Expect a problem in a short everyday context (a ticket queue, a game rule, a sorting process with cards, a delivery route) followed by parts such as:

  • work out the result by hand for given inputs;

  • trace a flowchart and complete a trace table, then state the output;

  • describe or construct an algorithm in numbered steps;

  • identify a pattern or a rule from worked cases;

  • identify a flowchart symbol or explain what part of a flowchart does;

  • suggest an improvement and justify it in terms of efficiency;

  • apply a computational thinking idea from subtopic B1.1, such as writing a problem specification or explaining how decomposition helps.

Answers are written in words, numbered steps, tables and diagrams. Writing Python or Java in this question is unlikely to gain anything extra, and it can cost marks if the question asks for steps a non-programmer could follow.

Exam tip

Read the whole question before starting. The early parts (working examples by hand, tracing) are usually designed to lead you to the pattern that later parts ask you to generalise or improve, so your answers to part (a) are tools for part (d).

The four-step algorithmic thinking process

The course guide describes algorithmic thinking as four steps. They are the most reliable way to attack an unfamiliar problem in this question, and each step matches a kind of question part.

Step

What you do

Question parts it answers

1. Explore with different parameters

Work the problem by hand for several small inputs

"Calculate the total for…", "State the output when…"

2. Record the steps

Write down exactly what you did for each case

the first draft of a "describe the algorithm" answer

3. Recognise the pattern and generalise

Replace the specific values with general ones

"Construct an algorithm…", "Identify the rule…"

4. Test and validate

Run the general steps on new inputs, including awkward ones, and refine for time and space

"Explain why the algorithm fails…", "Suggest an improvement…"

Computational thinking: the four steps use the ideas of subtopic B1.1: exploring and recording are decomposition of the problem into cases, step 3 is pattern recognition followed by abstraction (dropping the specific numbers), and the whole process is algorithmic design. Testing never proves an algorithm correct for every input, in the same way that experiments never prove a scientific theory; it builds confidence and exposes faults. An algorithm can also be justified by logic, showing why each step must work.

The process applied: giving change

A shop wants an algorithm that gives change using as few coins as possible. Its coins are worth 50, 20, 10, 5, 2 and 1 cents.

Steps 1 and 2, explore and record. Work several amounts by hand and write down every decision made, not only the answer.

Amount

Working, step by step

Coins

6

50, 20, 10 do not fit; 5 fits, leaving 1; 2 does not fit; 1 fits, leaving 0

5 + 1

37

50 does not fit; 20 fits, leaving 17; 10 fits, leaving 7; 5 fits, leaving 2; 2 fits, leaving 0

20 + 10 + 5 + 2

68

50 fits, leaving 18; 20 does not fit; 10 fits, leaving 8; 10 does not fit again; 5 fits, leaving 3; 2 fits, leaving 1; 1 fits, leaving 0

50 + 10 + 5 + 2 + 1

Step 3, generalise. In every case the same thing happened: take the largest coin that is not more than the amount left, subtract it, and repeat; when the largest coin no longer fits, move to the next smaller coin; stop when nothing is left. Written as numbered steps:

  1. Input the amount.

  2. Set the coin to the largest value, 50.

  3. While the amount is greater than 0, repeat steps 4 and 5.

  4. If the coin is less than or equal to the amount, output the coin and subtract it from the amount.

  5. Otherwise, set the coin to the next smaller value.

  6. Stop.

Step 4, test and validate. An amount of 0 outputs nothing, which is right. An amount of 1 skips five coins and outputs 1. An amount of 99 gives 50, 20, 20, 5, 2, 2: six coins, the minimum.

Testing with a different coin set exposes a limit. With coins of 25, 10 and 1, the same steps give 30 as 25 + 1 + 1 + 1 + 1 + 1 (six coins), but 10 + 10 + 10 uses only three. The algorithm is correct for the shop's coins but not for every coin system, and finding a limit of this kind is what a "test and validate" part asks for.

Common mistake

Testing only the examples that were used to build the algorithm. Those cases worked by construction, so they prove nothing new. Test with values the steps were not built from: zero, the smallest and largest possible inputs, a value on a boundary, and a case that breaks the pattern (here, a different set of coins).

Writing an algorithm in numbered steps

A numbered-steps answer must be precise enough that someone else could follow it without guessing. Examiners credit steps that say exactly what is compared, what changes and when the process stops. The comparison shows the difference between a vague answer and a creditable one for the change-giving problem.

Vague (little or no credit)

Precise (credited)

Use the biggest coins

Set the coin to the largest value, 50

Keep going until done

While the amount is greater than 0, repeat steps 4 and 5

Take away coins

If the coin is less than or equal to the amount, output the coin and subtract it from the amount

Try smaller ones

Otherwise, set the coin to the next smaller value

Follow these rules when you write steps:

  • One action per step, numbered, in the order they happen.

  • Name the values you keep track of ("the amount", "the coin", "the count") and use the same name every time, so each step clearly refers to the same thing.

  • Give every decision a precise condition, including whether a boundary counts: "greater than 0", "less than or equal to the amount".

  • Make loops explicit: "repeat steps 3 to 5 while…" or "for each ticket in the pile…", and make sure the loop can end.

  • Say what is output or returned, and when the algorithm stops.

  • Don't hide the task inside one word. If the question is about sorting, "sort the cards" is not an algorithm; the steps must show the comparisons and moves.

Exam tip

Each precise step often carries one mark: the initialisation, the loop and its condition, the decision, the update and the output. A paragraph of prose that contains the same ideas is harder to credit because the examiner has to search for each one. Number your steps even when the question does not insist on it.

Flowcharts

A flowchart shows an algorithm as standard symbols joined by arrows. You need to recognise each symbol, follow a flowchart exactly, and be able to draw a simple one.

Symbol

Shape

Use

Terminator

rounded rectangle (oval ends)

Start and End

Process

rectangle

a calculation or an assignment, such as amount = amount − coin

Input/output

parallelogram

data entering (Input amount) or leaving (Output coin)

Decision

diamond

a yes/no question with two labelled exits

flowline

arrow

the order in which symbols are followed

connector

small circle with a letter

joins two parts of a flowchart without a long line

The flowchart for the change-giving algorithm uses all six symbols. The loop is drawn as a flowline that returns to an earlier decision, and the connector A carries the flow from the "next smaller coin" box back to the main loop.

Flowchart: Start; input amount; coin = 50; decision amount > 0 (No to End). Yes: decision coin ≤ amount. Yes: output coin, amount = amount − coin, back to amount > 0. No: coin = next smaller coin, then connector A, which re-enters above amount > 0.Flowchart: Start; input amount; coin = 50; decision amount > 0 (No to End). Yes: decision coin ≤ amount. Yes: output coin, amount = amount − coin, back to amount > 0. No: coin = next smaller coin, then connector A, which re-enters above amount > 0.
Every loop in a flowchart is a decision plus a flowline back to an earlier point; following the arrows from each decision exit shows what repeats.

When you draw a flowchart yourself, put one action in each box, label both exits of every decision (Yes and No, or True and False), make each loop return to the decision that controls it, and use the right shape: a calculation in a parallelogram or an output in a rectangle loses the mark for that symbol.

Common mistake

Leaving a decision exit unlabelled or giving a decision only one exit. A diamond always has two exits, and the reader must be able to tell which is which. Draw the arrows first, then write Yes and No beside them before moving on.

Trace tables

To trace a flowchart is to follow it symbol by symbol and record every change in a trace table (tracing is taught in subtopic B1.1). The conventions are the same as for tracing code:

  • one column for each variable, in the order the variables first appear;

  • a column for each decision, if the question gives one, recording True/False or Yes/No;

  • a column for output, written exactly as it is produced;

  • a new row each time a value changes or a decision is made, so the order of events can be read from top to bottom.

If the question gives you a table with headings, use those headings and fill every row. If it gives a blank space, draw your own table with clear headings; a table is always clearer than a list of values in a sentence.

Worked example

Trace the change-giving flowchart for an input of 68, and state the output. [4]

Show the solution

One row for each decision reached, with the values at that moment:

amount

coin

amount > 0

coin ≤ amount

Output

68

50

Yes

Yes

50

18

50

Yes

No

18

20

Yes

No

18

10

Yes

Yes

10

8

10

Yes

No

8

5

Yes

Yes

5

3

5

Yes

No

3

2

Yes

Yes

2

1

2

Yes

No

1

1

Yes

Yes

1

0

1

No

Output: 50, 10, 5, 2, 1 (five coins).

Award [1] for the coin moving through 50, 20, 10, 5, 2, 1 at the right points, [1] for amount taking the values 68, 18, 8, 3, 1, 0, [1] for the loop ending when the amount is 0, [1] for the output in order. Check: 50 + 10 + 5 + 2 + 1 = 68.

The commonest tracing slips are the same on paper as in code: updating a value at the wrong moment (subtracting the coin before the decision that checks it), stopping one pass early or late, and recording an output the flowchart never produces. A careful tracer moves a finger along the flowlines and writes a row at each decision.

Tip

To trace a long flowchart quickly, number its symbols in pencil first (1, 2, 3…). Then each row of your table can note which symbol it records, and you can find your place again instantly after checking a value.

Reasoning about efficiency without code

Some parts ask which of two methods is more efficient, or ask you to suggest a faster one and justify it. Without code, measure efficiency by counting the basic steps (comparisons, additions, moves) a method needs for an input of size nn, and work out how that count grows as nn grows. The full theory is Big O notation in subtopic B2.4; for this question three ideas are usually enough.

  • One pass through the data costs about nn steps: checking each ticket once, adding up every value, a linear search. The count grows in proportion to nn.

  • Comparing every item with every other item, or a full pass for each item, costs about n×nn×n steps, so doubling nn makes the work four times as large.

  • Halving the data at each step, as in a binary search of sorted data, costs about log⁡2nlog2​n steps: 1,000 items need about 10 halvings.

State the worst case (the input that makes the method do the most work) unless the question asks for the best case, and say what causes it ("the missing ticket is the last number checked"). A good justification uses numbers: "for 1,000 tickets, at most 999,000 comparisons against 999 additions". The growth of the two kinds of cost for the raffle-ticket problem in worked example 2 shows why the difference matters for large inputs.

02468101214161820050100150200250300350400n (tickets)Steps (worst case)n = 20: 380 comparisonsn = 20: 19 additions
  • search the pile for each number: at most n(n−1)
  • add the tickets once: n − 1
A method that repeats a full pass for every item grows with the square of n, so it falls far behind a single pass even for 20 items.

Time is not the only cost. A faster method sometimes uses more memory, such as an extra list of n tick boxes, and a good "evaluate" answer names that trade-off.

Worked example 1: tracing a flowchart

A weather station records the rainfall, in whole millimetres, for each of n days. The flowchart finds a value from the readings.

Flowchart: input n; current = 0, longest = 0, day = 1. Decision day ≤ n: No outputs longest, ends. Yes: input rain; if rain = 0, current + 1 and, if current > longest, longest = current; else current = 0. Then day = day + 1, back to day ≤ n.Flowchart: input n; current = 0, longest = 0, day = 1. Decision day ≤ n: No outputs longest, ends. Yes: input rain; if rain = 0, current + 1 and, if current > longest, longest = current; else current = 0. Then day = day + 1, back to day ≤ n.
The variable current counts the present run of dry days and is reset by any rain; longest keeps the best run so far.

Worked example

(a) Identify the name of the symbol used for "Input rain". [1]

(b) Trace the flowchart for n = 8 with the rainfall readings 0, 0, 3, 0, 0, 0, 1, 0, and state the output. [5]

(c) State the output for n = 3 with the readings 2, 5, 1. [1]

(d) Describe what the flowchart calculates. [2]

(e) The station also wants to know the day on which the longest dry spell ended. Describe the changes needed to the flowchart. [3]

Show the solution

(a) Input/output symbol (parallelogram). [1]

(b) A first row for the starting values, then one row per day, showing the day being processed and the other values after that day's processing:

day

day ≤ n

rain

rain = 0

current

current > longest

longest

1

0

0

1

Yes

0

Yes

1

Yes

1

2

Yes

0

Yes

2

Yes

2

3

Yes

3

No

0

2

4

Yes

0

Yes

1

No

2

5

Yes

0

Yes

2

No

2

6

Yes

0

Yes

3

Yes

3

7

Yes

1

No

0

3

8

Yes

0

Yes

1

No

3

9

No

3

Output: 3.

Award [1] for each of: initial values 0, 0, 1; current reset to 0 on days 3 and 7; current counting up to 3 on days 4 to 6; longest changing only on days 1, 2 and 6; output 3.

(c) 0. [1] No reading is 0, so current is reset every day and longest never changes.

(d) The length of the longest run of consecutive days with no rain (0 mm) [1], among the n days entered [1].

(e) Award [1] for each of:

  • add a variable, for example end_day, set to 0 in the first process box;

  • in the box longest = current, also set end_day = day;

  • output end_day with longest at the end.

For the data in (b), end_day becomes 6, because the run of three dry days is days 4, 5 and 6.

Part (e) is a typical "modify the algorithm" part: each change is one mark, and a frequent loss is updating the new variable in the wrong place (after day = day + 1, which records the next day instead). When you revise, you can check a hand trace by coding the same algorithm; the Python version returns 3, 0 and 4 for the readings in (b), in (c) and for four dry days in a row.

Python
def longest_dry_spell(rain):
    current = 0
    longest = 0
    for amount in rain:
        if amount == 0:
            current = current + 1
            if current > longest:
                longest = current
        else:
            current = 0
    return longest


print(longest_dry_spell([0, 0, 3, 0, 0, 0, 1, 0]))
print(longest_dry_spell([2, 5, 1]))
print(longest_dry_spell([0, 0, 0, 0]))
Java version
Java
public class DrySpell {
    public static int longestDrySpell(int[] rain) {
        int current = 0;
        int longest = 0;
        for (int amount : rain) {
            if (amount == 0) {
                current = current + 1;
                if (current > longest) {
                    longest = current;
                }
            } else {
                current = 0;
            }
        }
        return longest;
    }

    public static void main(String[] args) {
        System.out.println(longestDrySpell(new int[] {0, 0, 3, 0, 0, 0, 1, 0}));
        System.out.println(longestDrySpell(new int[] {2, 5, 1}));
        System.out.println(longestDrySpell(new int[] {0, 0, 0, 0}));
    }
}

Worked example 2: designing and improving an algorithm

The second example has no flowchart: you build the algorithm yourself, then judge its efficiency. It follows the four-step process from exploring small cases to testing a better method.

A raffle uses tickets numbered 1 to n. After the draw, the box should contain every ticket, but exactly one is missing. The tickets in the box are in no particular order.

Worked example

(a) For n = 6, the box contains the tickets 4, 1, 6, 2, 5. State the missing ticket. [1]

(b) Method A checks each number from 1 to n in turn, searching the whole pile for it. Construct Method A as numbered steps. [4]

(c) Deduce an upper limit on the number of ticket comparisons Method A needs for n tickets, and explain how this number grows as n increases. [3]

(d) Suggest a more efficient method, and justify why it is more efficient. [4]

Show the solution

(a) 3. [1]

(b) One possible answer:

  1. Input n.

  2. Set k to 1.

  3. Compare k with each ticket in the pile, from the first to the last.

  4. If no ticket is equal to k, output k and stop.

  5. Otherwise, add 1 to k.

  6. Repeat from step 3.

Award [1] for each of: starting at 1; searching the whole pile for the current number; outputting the number when it is not found (and stopping); moving to the next number and repeating. Accept a stopping condition such as "while k ≤ n".

(c) There are n − 1 tickets in the pile, so each search makes at most n − 1 comparisons [1]. Up to n numbers may be searched for (the worst case is when n itself is missing) [1], so Method A never needs more than n × (n − 1) comparisons. (The true worst case is about half this, because each ticket sits in only one place in the pile, but it grows in the same way.) This grows with the square of n: doubling the number of tickets makes the worst-case work about four times as large; for 1,000 tickets it is 999,000 comparisons [1].

(d) Method B: add up the numbers on all the tickets in the pile (one pass), calculate the total that 1 to n should give, n(n+1)22n(n+1)​, and subtract; the difference is the missing ticket [2]. For n = 6: 4 + 1 + 6 + 2 + 5 = 18 and 6×72=2126×7​=21, so 21 − 18 = 3, matching (a).

Justification: Method B looks at each ticket exactly once, so it needs n − 1 additions plus one calculation, growing in proportion to n [1]; for 1,000 tickets that is 999 additions against up to 999,000 comparisons, and it needs no extra storage beyond the running total [1].

Accept instead: a list of n tick boxes, ticking each ticket's number and then finding the unticked box, which also takes about 2n steps but needs n extra items of memory.

Testing Method B, as step 4 of the process demands, means trying the awkward cases. If ticket 1 is missing (tickets 2 to 6, total 20), it gives 21 − 20 = 1; if ticket n is missing, it gives n. Passing these tests shows only that the method works for the cases tried. Here a logical argument completes the job: the full total minus the total of the tickets present can only equal the number of the absent ticket, so the method is correct for every n.

Tip

Improve your notes: Make a one-page "pattern bank" of the shapes that keep returning in this question: running total, count, best-so-far, current run, search until found, swap neighbours. For each, write the numbered steps, a three-symbol flowchart fragment and one sentence on its efficiency. When a new problem appears, look for which patterns it combines.

Checklist

  • To do:

    I know that one compulsory Paper 2 question has no code, and that it is also on the HL paper.

  • To do:

    I can apply the four steps: explore small cases, record the steps, generalise, test and validate.

  • To do:

    I test an algorithm with zero, one item, boundary values and a case that breaks the pattern.

  • To do:

    I can write an algorithm as numbered steps, one action per step, with precise conditions and an explicit loop and stop.

  • To do:

    I can name and draw the six flowchart symbols and label both exits of every decision.

  • To do:

    I can trace a flowchart with a trace table, one row per decision or change, and state its output.

  • To do:

    I can describe in words what a flowchart calculates.

  • To do:

    I can modify an algorithm by adding a variable, its initial value, its update and its output.

  • To do:

    I can compare two methods by counting steps for n items in the worst case.

  • To do:

    I can suggest a more efficient method and justify it with numbers and a time–space trade-off.

Keep your place

In Augment the notes remember where you stopped and which pages you have finished.

Open in Augment

More IB Computer Science notes

  • Paper 2: reading and writing codeThe page before this.
  • What changes at HLThe next page. HL only.
  • Computer Science assessmentEach Computer Science paper, the internal assessment and grade boundaries.
  • IB Computer ScienceThe Computer Science syllabus, how it is assessed and every notes page.

Carry on with Computer Science in Augment

With a free account, Augment remembers where you stopped in the notes and which questions you have marked.

Start free