Computational thinking
- Decomposition means breaking a problem down into smaller parts that are easier to solve.
- Abstraction means removing unnecessary detail so you can focus on what matters. A map of the London Underground shows the stations and how they connect, but not the real distances.
- Algorithmic thinking means working out the steps needed to solve a problem, in the right order.
Algorithms
- An algorithm is a sequence of steps that completes a task. A program is an algorithm written in a programming language, so a computer can run it.
- Algorithms are built from three things: sequence (steps in order), selection (choosing a path, such as with IF) and iteration (repeating steps with a loop).
- Before designing, identify the inputs, processes and outputs. For a program that works out the area of a rectangle, the inputs are the length and width, the process is length × width, and the output is the area.
Structure diagrams and trace tables
- A structure diagram shows a problem broken down into smaller sub-problems, from the top down.
- A trace table records the value of each variable as an algorithm runs, step by step. Working through an algorithm by hand like this (a dry run) helps you find errors.
Efficiency
- More than one algorithm can solve the same problem. A more efficient algorithm takes fewer steps (less time) or uses less memory.
- For example, a binary search finds an item in a large sorted list in far fewer steps than a linear search.
Key terms
- Algorithm
- A sequence of steps that completes a task.
- Decomposition
- Breaking a problem down into smaller, more manageable parts.
- Abstraction
- Removing unnecessary detail to focus on the important parts of a problem.
- Algorithmic thinking
- Working out the steps needed to solve a problem.
- Sequence
- Instructions carried out one after another, in order.
- Selection
- Choosing which path to follow, depending on a condition.
- Iteration
- Repeating a set of instructions.
- Trace table
- A table that records the values of variables as an algorithm runs.
- Structure diagram
- A diagram showing a problem broken down into sub-problems.
Quick questions on Computational thinking and algorithms
- What is decomposition?
- Breaking a problem into smaller, more manageable parts: Each small part is easier to solve.
- What is abstraction?
- Removing unnecessary detail to focus on what matters: It simplifies a problem.
- A Tube map shows stations and lines but not real distances. Which technique is this?
- Abstraction: Unneeded detail has been removed.
- What is an algorithm?
- A sequence of steps that completes a task: A recipe is an everyday example.
- Which three building blocks are all algorithms made from?
- Sequence, selection and iteration: Every algorithm can be written using just these three.
- What is selection?
- Choosing which path to follow, for example with IF: The path depends on a condition.
- What is iteration?
- Repeating a set of steps: Loops are used for iteration.
- What is a trace table used for?
- Recording the values of variables as an algorithm runs: It helps you find errors by hand.
Computational thinking and algorithms: questions and answers
- A program asks for a length and a width, then displays the area. What is the output?
- The area. The length and width are inputs.
- What does a structure diagram show?
- A problem broken down into smaller sub-problems. It is a picture of decomposition.
- What makes one algorithm more efficient than another?
- It solves the problem in fewer steps or with less memory. Efficiency is about time and memory.
Practise Computational thinking and algorithms: 12 questions