Skip to main content

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:

  1. Find out how many hours are worked
  2. Find out how many of those hours are to be paid at the normal rate
  3. Find out how many, if any, of those hours are to be paid at the overtime rate
  4. Work out the pay for the normal hours
  5. Work out the pay for the overtime hours
  6. Total the pay for normal and overtime hours
  7. Output the result

Here is an amazing video that tells you more about Decomposition and its applications.

Click to watch

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!
Answer: 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.

🎨 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)