You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson covers decomposition in detail, as required by OCR J277 Section 2.1. Decomposition is one of the four key components of computational thinking and is often the first step in solving any complex problem.
Decomposition is the process of breaking a complex problem down into smaller, more manageable sub-problems. Each sub-problem can then be understood, solved, and tested individually before being combined into a complete solution.
Think of decomposition like building a house:
| Reason | Explanation |
|---|---|
| Makes problems manageable | Smaller sub-problems are easier to understand and solve than one large, complex problem |
| Enables teamwork | Different people or teams can work on different sub-problems simultaneously |
| Facilitates testing | Each sub-problem can be tested independently, making it easier to find and fix errors |
| Promotes code reuse | Solutions to common sub-problems can be reused in other projects |
| Improves clarity | A decomposed problem is easier to communicate to others |
OCR Exam Tip: When asked why decomposition is important, always mention that it makes complex problems easier to solve by breaking them into smaller parts. Also mention that it allows different sub-problems to be worked on independently and tested separately.
A student wants to create a simple quiz game. Without decomposition, this is one big, overwhelming task. With decomposition:
| Sub-Problem | Detail |
|---|---|
| User interface | Design the screen layout, buttons, and text display |
| Question storage | Decide how to store questions and answers (list, file, database) |
| Displaying questions | Write code to show questions one at a time |
| Getting user input | Write code to accept the user's answer |
| Checking answers | Compare the user's answer to the correct answer |
| Scoring | Keep track of the score and display it |
| Feedback | Tell the user if they are right or wrong |
| End of game | Display the final score and offer to play again |
Each of these sub-problems can be solved independently and then combined to create the complete game.
| Main Problem | Sub-Problems |
|---|---|
| Build an online shop | Browse products, search products, add to basket, manage basket, create account, log in, enter delivery address, process payment, confirm order, send email confirmation, update stock levels |
| Main Problem | Sub-Problems |
|---|---|
| Build a registration system | Take the register (present/absent/late), store attendance data, calculate attendance percentages, generate reports for form tutors, send alerts for persistent absence, display attendance on student profiles |
The following tree diagram illustrates how a complex problem is decomposed into sub-problems:
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.