Computational Thinking - Decomposition
Decomposition is one of the four cornerstones of Computer Science. It involves breaking down a complex problem or system into smaller parts that are more manageable and easier to understand. The smaller parts can then be examined and solved, or designed individually, as they are simpler to work with.
Why is decomposition important?
If a problem is not decomposed, it is much harder to solve. Dealing with many different stages all at once is much more difficult than breaking a problem down into a number of smaller problems and solving each one, one at a time. Breaking the problem down into smaller parts means that each smaller problem can be examined in more detail.
Similarly, trying to understand how a complex system works is easier using decomposition. For example, understanding how a bicycle works is more straightforward if the whole bike is separated into smaller parts and each part is examined to see how it works in more detail.
Problem statement
An employee's weekly pay depends on the rate of pay and the number of hours worked per week. Employees work a minimum of one hour per week, and a maximum of 60. An employee who works more than 40 hours is paid 1.5 times the normal pay rate for all hours worked over 40. Normal pay is £10 per hour. A program is required to calculate and output the weekly pay for any employee.
Decompose the problem
The first step is to break down (decompose) the overall problem into several smaller, more easily solved problems:
- Find out how many hours are worked
- Find out how many of those hours are to be paid at the normal rate
- Find out how many, if any, of those hours are to be paid at the overtime rate
- Work out the pay for the normal hours
- Work out the pay for the overtime hours
- Total the pay for normal and overtime hours
- Output the result
Here is an amazing video that tells you more about Decomposition and its applications.
Source: coursera
Check-point Assessment
Q1: Which of these is an example of decomposition?
A. Breaking the problem of organising a cake sale into smaller parts, such as who will bake the cakes and when to hold the cake sale.
B. Taking the problem of baking a cake and thinking about how we can make it the best cake possible.
C. Looking at what different kinds of cake can be made.
D. None of the above
Check the Solution!
🎨 An activity applying Decomposition
Think of a problem for which you could use computational thinking, describe it, and then describe how you would apply decomposition. You should describe at least 2 sub-problems.
(Add a text box here)