Decomposing a problem simply means breaking it down into a set of smaller problems which can be solved more easily. It is a useful way of tackling any task or problem which seems to difficult to solve in one go. Here are some examples.
A recipe is a good example of decomposition. It provides step by step instructions, for example to make a Victoria sponge:
Even if you have never baked a cake before, and don't have a clue how to do it, when it is broken down into steps like this it becomes much easier. Each one of the steps looks quite straightforward, and if you follow them carefully you will have some kind of cake at the end.
We sometimes have to decompose a problem in more than one way in order to fully understand it. For example the recipe above needs an ingredients list, giving the weight of butter, sugar and flour to use, and how many eggs. It might also give us a list of the equipment we need (bowl, weighing scales, mixer, cake tin). So in this case we analyse the task of baking a cake, breaking down:
Analysing the cake in this way also allows us to work out:
As another example of decomposition, think about what you might do if you have a homework essay to write.
You could just dive in and start writing, but you might find that isn't the best idea. It is usually better to plan first, to decide what are the key points or arguments you want to get across. Then choose examples that best illustrate your points. When you put this all together, you will have a clear and coherent essay.
For example, here is what I did when writing the page you are reading right now. First I decided on the main points:
You might want to make a list, or even a mind map at this point.
So next I decided what examples I wanted to use - baking a cake, writing an essay, and drawing a square using turtle graphics (the next section).
Decomposition involves analysis - looking at the task or problem and deciding how to break it down. In the example of baking a cake, the analysis was done for us by the author of the cookbook. But when you are writing an essay, you must do the analysis yourself.
After the analysis stage, you must bring all the parts together when you finally write your essay - the process of synthesis. You have decided what the main sections will be, and you have a list of bullet points to include, but you still have to write the words
Turtle graphics provide a simple, graphical programming environment. This allows us to explore computational thinking topics without getting bogged down in complicated code. This example will be extended to look at the other topics - recognising patterns, abstraction and algorithms.
Here is a square drawn with the turtle:
As before, we want to decompose the task of drawing the square. Here it is in stages:
This analysis shows us how to draw the square - by moving and turning 4 times. Here is the Python code to draw it (if you are using a different Turtle system, it should be easy to translate the commands):
import turtle turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90) turtle.forward(100) turtle.left(90)
Copyright (c) Axlesoft Ltd 2021