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:
graph TD
A["Create a Quiz Game"] --> B["User Interface"]
A --> C["Question Handling"]
A --> D["Scoring"]
B --> B1["Design question screen"]
B --> B2["Design results screen"]
B --> B3["Design main menu"]
C --> C1["Load questions from file"]
C --> C2["Randomise order"]
C --> C3["Display question"]
D --> D1["Track correct answers"]
D --> D2["Calculate percentage"]
D --> D3["Display final score"]
Decomposition can happen at multiple levels. A sub-problem can itself be decomposed further:
Level 1: Create a quiz game
This hierarchical decomposition can be represented as a structure diagram (which we will cover in a later lesson).
In programming, decomposition leads naturally to the use of subprograms (functions and procedures):
| Decomposed Sub-Problem | Subprogram |
|---|---|
| Display a question | displayQuestion() |
| Check the answer | checkAnswer() |
| Update the score | updateScore() |
| Show the final result | showResult() |
Each subprogram handles one specific task, making the code:
Follow these steps:
OCR Exam Tip: In the exam, you may be given a scenario and asked to decompose it into sub-problems. List each sub-problem clearly and make sure they are specific (not vague). For example, "process payment" is better than "do the money bit." If appropriate, show multiple levels of decomposition.
Question: A school wants to create a system to manage library book loans. Decompose this problem into sub-problems.
Answer:
Decomposition is the process of breaking complex problems into smaller, manageable sub-problems. It is the essential first step in computational thinking and leads directly to well-structured programs. Each sub-problem can be solved, tested, and debugged independently. For the OCR J277 exam, practise decomposing real-world problems into clear, specific sub-problems.
Scenario: A small independent cinema wants to build a web-based ticket booking system. Customers should be able to browse films, choose a showing, select seats, pay, and receive a digital ticket. Staff should be able to add films, set showing times, and view sales reports. The owner has never commissioned a piece of software before and has given the developers only this one paragraph of description — so the first job is to turn that paragraph into a structured decomposition that the team can actually build from.
Step 1 — State the overall goal clearly. Build a ticket booking system for a cinema, usable by both customers and staff, that handles browsing, booking, payment, and reporting.
Step 2 — Identify the top-level sub-systems. Before listing tasks, split the system by major responsibility:
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.