Computational thinking

GCSE Computer Science (OCR) · OCR J277 · 2.1.1 · Algorithms and programming (Paper 2) › Algorithms

75 exam-style questions on this topic, at up to four difficulty levels, with full mark schemes. Notes and past-paper booklets are open to everyone. Practice needs a free account.

Or take a quick quiz: 10 questions on this subtopic in GCSE Computer Science (OCR), marked as you tap.

Revision notes

Computational thinking is the way you break down and simplify a problem so that a computer can solve it. It has three parts: abstraction, decomposition and algorithmic thinking. Expect short definitions and questions that ask you to apply the terms to a scenario.

Key facts

  • Abstraction = removing unnecessary detail to focus on what matters
  • Decomposition = breaking a problem into smaller sub-problems
  • Algorithmic thinking = working out the steps, in order, that solve the problem
  • Algorithm = a sequence of steps that solves a problem
  • Benefits of decomposition: easier to code and test, shared between a team, parts reused
  • Benefits of abstraction: a simpler problem and less to program

Notes

The three parts of computational thinking

  • Abstraction: removing or hiding details that are not needed, so you can focus on what matters for the problem.
  • Decomposition: breaking a complex problem into smaller sub-problems. Each sub-problem can be broken down again until every part is simple enough to solve.
  • Algorithmic thinking: identifying the steps needed to solve the problem and putting them in the right order, so the solution can be followed by a computer. It includes spotting where a decision is needed and where steps repeat.

Abstraction in practice

diagram
  • A map of a train line shows the stations and the order they come in, but leaves out the true distances, the shape of the track and the buildings nearby.
  • Real routeMap (abstraction)AshBayColeDaleAshBayColeDale
    Abstraction: the map keeps only what matters, the stations and their order
  • A program that simulates rolling a dice only needs a number from 1 to 6. The colour, size and weight of a real dice are abstracted away.
  • To decide whether a detail can be removed, ask: does the program need it to produce the correct result? If not, leave it out.
  • Abstraction makes the problem simpler, so the program is easier and quicker to write.

Decomposition in practice

diagram
  • A quiz game could be decomposed into: load the questions, ask a question, check the answer, update the score, show the final score.
  • Quiz gameLoadquestionsAskquestionCheckanswerUpdatescoreShow finalscore
    Decomposition of the quiz game into sub-problems
  • Each sub-problem is smaller, so it is easier to design, code and test.
  • Different programmers can work on different parts at the same time, so the program is finished sooner.
  • Parts can be written as sub programs and reused, and errors are easier to find because each part can be tested on its own.
  • Decomposition is often shown as a structure diagram.

Algorithmic thinking in practice

  • Think about the inputs, the order of the steps, where a decision is needed (selection) and what repeats (iteration).
  • Example: to find the highest score in a list, take the first score as the highest so far, compare each of the other scores with it in turn, replace it when a score is higher, then output it at the end.

How to answer each type of question

Define a computational thinking term

1 to 2 marksGrade 3
  1. Give the core idea: removing detail (abstraction), breaking down (decomposition) or working out the steps in order (algorithmic thinking).
  2. For a second mark, add what it achieves or a short example.

Example. Define the term decomposition. [2]

Show the model answerHide the model answer
Breaking a problem down into smaller sub-problems (1) so that each part is easier to understand and solve / can be tackled separately (1).

Apply abstraction to a scenario

2 to 4 marksGrade 5
  1. Read what the program has to do.
  2. Details it does not need to do that job have been removed (abstracted).
  3. Details it needs to do that job are kept.
  4. Use the objects named in the scenario, not general answers.

Example. A school is writing a program that simulates a fire drill. It shows students moving from their classrooms to the exits on a plan of the school.
Give two details that could be removed by abstraction, and one detail that must be kept. [3]

Show the model answerHide the model answer
Removed, any two: the colour of the walls / the names of the students / the pictures on display / what the students are wearing (1 each, max 2).
Kept: the positions of the corridors, doors and exits / the number of students in each room
(1).

Decompose a problem

3 to 4 marksGrade 6
  1. Read the scenario and list the separate jobs the system must do.
  2. Give each sub-problem a short name: a verb and a noun, such as 'calculate the cost'.
  3. Make sure each one is a genuine part of the problem, not a restatement of the whole question.

Example. A cinema wants a program that lets customers book tickets online.
Decompose the problem into four sub-problems. [4]

Show the model answerHide the model answer
Any four, 1 mark each: display the films and showing times (1); let the customer choose seats and check they are free (1); calculate the total cost (1); take the payment (1); send a confirmation of the booking (1).

Explain the benefits of decomposition

2 to 4 marksGrade 7
  1. State a benefit.
  2. Explain why it helps, linked to the scenario if there is one.
  3. Repeat for the second benefit.

Example. A team of programmers is writing a large program for a bank.
Explain two benefits of decomposing the problem. [4]

Show the model answerHide the model answer
Each sub-problem is smaller (1) so it is easier to code and test on its own
(1).
Different programmers can work on different sub-problems at the same time (1) so the program is completed more quickly
(1).
Also accept: parts can be reused (1) as sub programs in other programs
(1).

Don’t lose marks

  • Mixing up abstraction (removing detail) and decomposition (breaking down).
  • Defining abstraction as 'making it simple' without saying that unnecessary detail is removed.
  • Giving general answers when the question is about a scenario. Use the scenario's objects.
  • Listing sub-problems that are vague, such as 'do the program', or that just repeat the question.

More tips

Memory tricks

  • Abstraction = Away with detail. Decomposition = Divide it up. Algorithmic thinking = Arrange the steps.
  • Detail test for abstraction: 'Would the program give a different result without this?' If not, it can be removed.
  • When you see 'decompose', think of a structure diagram: the whole problem at the top, smaller jobs underneath.

Exam technique

  • Learn the three definitions word for word: they are quick marks.
  • 'Identify' or 'State' needs a short answer; 'Explain' needs a point and a reason ('... so that ...').
  • In scenario questions, every point you make should mention something from the scenario.

What each grade needs

What you need to be able to do, from the first marks up to the top grade.

  1. Grade 3
    Define abstractionAbstraction is removing unnecessary detail so you can focus on the parts of a problem that matter.
  2. Grade 3
    Define decompositionDecomposition is breaking a problem down into smaller sub-problems that are easier to solve.
  3. Grade 4
    Define algorithmic thinkingAlgorithmic thinking is working out the steps needed to solve a problem and the order they must happen in.
  4. Grade 5
    Apply abstraction to a scenarioSay which details a program or model keeps and which it ignores, using the scenario's own objects.
  5. Grade 6
    Decompose a given problem into sub-problemsSplit a system, such as a booking app or a game, into sensible named tasks.
  6. Grade 7
    Explain the benefits of decompositionSmaller parts are easier to code and test, can be shared between programmers and can be reused.

Quick recall

Cover the answers and test yourself. The app has these as flashcards that come back just before you'd forget them.

Give one other sub-problem that the program would need to solve.
Check that tickets are still available.
The steps for making toast have been listed in the wrong order.
A Spread butter on the toast
B Put the bread in the toaster
C Push the lever down
D Take the toast out when it pops up
Write the letters in the correct order.
B, C, D, A
Write one line of code that uses drawSquare to draw a square with sides of 80.
drawSquare(80)
A teacher writes an algorithm for a class register.
  1. Set absent to 0.
  2. Look at each pupil in the class in turn.
  3. If the pupil is marked absent, add 1 to absent.
  4. Display absent.
State what the algorithm finds out.
The number of pupils who are absent.
State what is meant by an algorithm.
A sequence of steps that solves a problem.

Sample questions

Written for this site in the style of OCR exam questions. They are not taken from real past papers.

Question 1Easy3 marks
(a) Which statement best describes abstraction?
Tick (✓) one box.
[1]
  • Breaking a problem down into smaller sub-problems
  • Removing unnecessary detail so that only the important parts of a problem are considered
  • Writing the steps needed to solve a problem in a logical order
  • Checking that a program works using a range of test data
(b) State what is meant by decomposition.
[1]
(c) Give one benefit of decomposing a problem before writing a program.
[1]
Show the answer and mark scheme
(a) Answer: Removing unnecessary detail so that only the important parts of a problem are considered
(b)
  • breaking a (complex) problem down into smaller (more manageable) sub-problems / parts / tasks
(c)
  • each sub-problem is simpler / easier to understand, code or test
  • different sub-problems can be worked on by different programmers (at the same time)
  • the sub-programs produced can be reused (in this or other programs)
  • errors are easier to find / the program is easier to maintain
Question 2Medium5 marks
A leisure centre wants a program that lets members book places on fitness classes online. The programmer uses decomposition to plan the program.
(a) Identify three sub-problems that the programmer could split this problem into.
[3]
(b) Explain one way in which decomposition will help the programmer.
[2]
Show the answer and mark scheme
(a)
  • logging in / checking the member’s username and password
  • displaying the timetable / list of classes
  • checking whether a class has spaces left
  • recording / saving a booking
  • taking payment
  • sending a confirmation (email / message) to the member
  • cancelling a booking
(b)
  • a benefit, e.g. each sub-problem is smaller / simpler / can be tackled one at a time / can be given to different programmers / can be tested separately
  • linked explanation, e.g. so the program is quicker / easier to write / so errors are easier to locate and fix / so modules can be reused
Question 3Hard6 marks
A city council wants a computer model to try out different timings for the traffic lights at a busy crossroads before it changes the real lights.
(a) Describe how abstraction could be used when creating the model.
[3]
(b) Describe how decomposition could be used when creating the model.
[3]
Show the answer and mark scheme
(a)
  • remove details that do not affect the flow of traffic, e.g. the make / colour of the cars, drivers’ names, nearby buildings
  • keep the details that do affect the flow of traffic, e.g. number of vehicles arriving per minute, light timings, number of lanes
  • represent vehicles simply, e.g. as a number in a queue / all the same size and speed
  • this makes the model simpler / quicker to create / quicker to run
  • but enough detail must be kept for the results to be realistic / useful
(b)
  • split the model into smaller parts / modules / sub-programs
  • identifies a suitable part, e.g. controlling the sequence of the lights / generating arriving vehicles
  • identifies a second suitable part, e.g. moving vehicles through the junction / recording queue lengths or waiting times
  • each part can be developed / tested separately / by different people
  • parts can be broken down further until each one is easy to solve

Stuck? Get 1-to-1 help.

Chhetri Academy tutors GCSE and A level Maths and Science online, with a free 30-minute trial lesson.