Computer ScienceFoundation20 min read

Computational Thinking

Breaking a problem down until every piece is something you can actually do

This topic appears in:

01

Four habits, not four topics

Computational thinking is a way of approaching a problem so that a computer — or a person following instructions exactly — could solve it. It is not programming; you can do it on paper, and it is the part that decides whether the eventual program works.

The syllabus names four components, and they are used together rather than in sequence.

  • Decomposition — break a large problem into smaller sub-problems, each small enough to solve on its own. "Build a school management system" is unapproachable; "record one student's attendance" is not.
  • Pattern recognition — spot what the sub-problems have in common. If registering a student and registering a teacher differ only in one field, one solution can serve both.
  • Abstraction — ignore the detail that does not matter for the problem at hand. A map of the bus routes leaves out every building, and is more useful for its purpose because of it.
  • Algorithm design — write the sequence of steps that solves the problem, precisely enough that following them requires no judgement.

Abstraction is about what you leave out

Students often describe abstraction as "simplifying", which is close but loses the point. The skill is deciding which details are irrelevant for this problem. A city map for a driver shows one-way streets and omits contours; a map for a hiker does the opposite. Neither is a worse map — they abstract away different things.

02

What makes something an algorithm

Definition

Algorithm — A finite, ordered set of unambiguous instructions which, when followed, solves a problem or completes a task in a finite number of steps.

An algorithm is a finite sequence of unambiguous steps that solves a problem or performs a task. Each word in that definition is doing work, and questions test them.

Finite: it must stop. A set of instructions that loops for ever is not an algorithm. Unambiguous: each step must have exactly one interpretation — "add a little salt" fails, "add 5 grams of salt" passes. And it must have defined inputs and outputs, so you know what it needs and what it produces.

Written asLooks likeBest for
Flowchartboxes and arrowsseeing the flow of control at a glance
Pseudocodestructured Englishlonger algorithms, and translating to code
Structured Englishordinary sentences, numberedexplaining to a non-programmer
03

Flowcharts

A flowchart shows the order in which steps happen, using a fixed set of shapes. The shapes are part of the answer: using a rectangle where a diamond belongs loses the mark even if the logic is right.

Every flowchart has exactly one START and at least one STOP. A decision diamond has exactly two exits, labelled Yes and No, and every arrow carries an arrowhead so the direction is unambiguous.

The decision diamond is the only shape with two ways out, and both branches must be labelled. An unlabelled branch is the most common reason a correct flowchart still loses a mark.

04

Pseudocode

Pseudocode sits between English and a real programming language. It has no fixed standard, so the paper accepts any consistent style — but it must be structured, indented, and unambiguous.

Use keywords for the control structures, indent everything inside a block, and give variables meaningful names.

Worked example

Write an algorithm, in pseudocode, that reads 10 numbers and outputs the largest.

  1. Read the first number and use it as the starting value for largest.Setting largest = 0 to begin with fails if every number entered is negative — 0 would then win. Using the first actual value avoids the problem entirely.
  2. INPUT largest then FOR count = 2 TO 10The loop runs nine more times, because the first number has already been read.
  3. INPUT number then IF number > largest THEN SET largest = numberCompare each new value with the best so far, and replace it only when it is bigger.
  4. NEXT count then OUTPUT largestThe output belongs outside the loop; putting it inside would print ten times.

Read the first value as the initial largest, then compare the remaining nine, replacing when bigger.

Where the output statement goes

Inside the loop, OUTPUT largest runs on every pass and prints ten lines. Outside, it runs once with the final answer. Indentation is what shows the examiner which you meant, which is why unindented pseudocode can lose marks even when the logic is correct.

05

Testing an algorithm before it is code

A dry run or trace table checks an algorithm by hand. Make one column per variable, one row per pass through the loop, and write down what every variable holds at each step. Errors show up immediately, and finding them here is far cheaper than finding them after the program is written.

Choose test data deliberately: normal values that should work, boundary values at the edges of what is allowed, and erroneous values that should be rejected. An algorithm that handles only normal data is not finished.

Before you leave this chapter

  1. Decomposition, pattern recognition, abstraction, algorithm design.
  2. Abstraction means deciding which details to leave out for this particular problem.
  3. An algorithm must be finite and unambiguous, with defined inputs and outputs.
  4. Flowchart shapes are marked: rounded for start/stop, parallelogram for I/O, rectangle for process, diamond for decision.
  5. Trace an algorithm with a table before coding it, using normal, boundary and erroneous data.

Practice questions

6 questions · 20 marks · full working on every one

Try each one on paper first, then open the working. The marks are shown where they are actually awarded, because that is where they are actually lost.

Short questions

3 · 6 marks

Two marks each, in the style of the short-question section of the paper. Answer in two or three lines.

SQ1[2 marks]
Define an algorithm.
Model answer

A finite sequence of unambiguous instructions that solves a problem or completes a task, with clearly defined inputs and outputs.

Examiner tip. The words "finite" and "unambiguous" are each worth credit. A definition of "a set of steps" alone usually scores nothing.

SQ2[2 marks]
Explain what is meant by abstraction, with an example.
Model answer

Abstraction is removing the details that are not relevant to the problem being solved, so that the essential structure is easier to work with. A metro map shows the order of the stations and the connections between lines, but omits real distances and street layout — which makes it more useful for planning a journey, not less.

Examiner tip. The example is worth a mark on its own, and a map is the fastest one to write.

SQ3[2 marks]
State two differences between a flowchart and pseudocode.
Model answer

A flowchart is graphical, using standard shapes and arrows, and shows the flow of control visually. Pseudocode is textual, resembles program code and is quicker to write and to translate into a real language. Flowcharts become unwieldy for long algorithms, where pseudocode stays readable.

Examiner tip. Any two clear differences earn the marks. Graphical versus textual is the safest first point.

Solved numericals

2 · 8 marks

Full working, one step per line, with the marks shown where they are awarded.

N1[4 marks]
Write an algorithm in pseudocode that reads a student's marks out of 100 and prints "Pass" if the mark is 40 or more and "Fail" otherwise. Include validation that rejects marks outside 0–100.
Full working
  1. INPUT mark[1]
  2. Validation: WHILE mark < 0 OR mark > 100 → OUTPUT "Invalid" and INPUT mark againa loop, not a single if — the user may enter a bad value twice[1]
  3. IF mark >= 40 THEN OUTPUT "Pass"the >= is required; > alone fails a mark of exactly 40[1]
  4. ELSE OUTPUT "Fail" ENDIF[1]

Input with a validation loop, then IF mark >= 40 output Pass ELSE output Fail.

Examiner tip. Validation should loop rather than test once, because a user who typed 150 may type 200 next. A single IF that gives up after one bad value is only half a validation.

N2[4 marks]
Complete a trace table for this algorithm with input 4: SET total = 0; SET i = 1; WHILE i <= n DO total = total + i; i = i + 1; ENDWHILE; OUTPUT total
Full working
  1. Columns for n, i, total, and outputone column per variable[1]
  2. After pass 1: i = 2, total = 1; after pass 2: i = 3, total = 3[1]
  3. After pass 3: i = 4, total = 6; after pass 4: i = 5, total = 10[1]
  4. The loop ends because 5 > 4; output is 10the algorithm sums 1 to n[1]

Output 10 — the algorithm computes 1 + 2 + 3 + 4.

Examiner tip. Write a new row every time a variable changes, not once per line of code. That is what makes the moment the loop condition fails visible.

Long questions

1 · 6 marks

Theory and numerical together, as they appear in the long-question section.

LQ1[6 marks]
A school wants a program that records attendance for every class each day and produces a monthly report.
  1. Describe how decomposition would be applied to this problem.
  2. Give one example of abstraction in this system.
  3. Explain why the algorithm should be tested with boundary data, giving one example of such data.
Mark scheme
  1. Break the system into separate sub-problems, such as: record one student's attendance; store a day's records; calculate one student's monthly totalat least two named sub-problems[1]
  2. And: produce the report; handle login. Each is small enough to be designed and tested on its ownthe reason for decomposing is part of the answer[1]
  3. Abstraction: store only what the task needs — a student's roll number and present/absent flag — and ignore irrelevant details such as their address or hobbies[1]
  4. The unnecessary detail would make the system larger and slower without improving the report[1]
  5. Boundary data tests the values at the edges of what is acceptable, which is where most errors occur[1]
  6. Example: a month with 31 days, or a class with exactly one student, or an attendance percentage of exactly 75% if that is the pass thresholdany sensible boundary value[1]

(a) split into recording, storing, calculating and reporting (b) store only roll number and present/absent (c) edges are where errors hide — e.g. exactly 75% attendance

Examiner tip. Boundary data means the value at the limit, not just outside it. If the rule is "75% or more", the boundary values to test are 74, 75 and 76.