Preparing a result sheet for a whole class looks like a large task. It becomes manageable when divided: read the marks, check them, total them, compute averages and print the sheet. Dividing a large problem into smaller ones is called decomposition.
What Is Decomposition?
Definition: Decomposition. The process of dividing a large problem into smaller subproblems, each with a clear purpose, a clear input and a clear result.
Each subproblem is solved separately, and the partial solutions are then combined to solve the original problem. A subproblem that is still too large can itself be divided further.
Connecting the Parts
For the task of finding a class average, the work can be divided
The parts depend on one another. The average cannot be calculated until the total and the count are known, and the total should include only scores that passed validation. The result that one subproblem produces becomes the input of another. Table 1.9 states this for each part.
Table 1.9: What each subproblem receives and produces
| Subproblem | Receives | Produces |
|---|---|---|
| Read the scores | Values typed by the user | A list of scores |
| Validate the scores | The list of scores | Only the valid scores |
| Add the scores | The valid scores | Total and count |
| Divide by the count | Total and count | The average |
| Display the average | The average | A readable message |
Why Decomposition Helps
Decomposition offers several benefits.
- Understanding: a small task can be held in the mind at once.
- Checking: each part can be tested separately, so an error is easier to locate.
- Reuse: a part such as "validate a score" can be used again in other problems.
- Sharing of work: different people can work on different parts.
Qualities of a Good Division
A good division gives every subproblem one clear job. Parts should not repeat each other's work, and nothing should be left unassigned between them. Above all, the handoff between parts must be stated: what each part receives and what it must produce. Hidden assumptions at the handoff, such as assuming that scores are already valid, are a common cause of errors.
In Unit IV, subproblems become functions in C, and this style of design is called modular programming.
Example 1.9: Decomposing a bill calculation
Problem: Decompose the task "prepare a shop bill with 5 per cent tax" and solve it for 3 notebooks at 40 rupees each and 2 pens at 15 rupees each.
Solution:
- Subproblem 1, item amounts: 3 × 40 = 120 and 2 × 15 = 30.
- Subproblem 2, subtotal: 120 + 30 = 150.
- Subproblem 3, tax: 5 per cent of 150 = 7.50.
- Subproblem 4, final amount: 150 + 7.50 = 157.50.
- Subproblem 5, display: show the subtotal, the tax and the final amount.
Result: The bill is 157.50 rupees. Each subproblem used the result of the one before it.
Common mistakes
- Dividing a problem into parts without stating what each part receives and produces.
- Creating parts that overlap, so the same work is done twice.
- Assuming that another part has already checked the data when no part was given that job.
Key takeaways
- Decomposition divides a large problem into smaller subproblems.
- Each subproblem has a clear purpose, input and result.
- The output of one subproblem is often the input of another.
- Smaller parts are easier to understand, test and reuse.
Practice questions
- What is decomposition?
- In the class-average problem, which subproblem must finish before "divide by the count"?
- Give two benefits of decomposition.
Answers to the practice questions
- Dividing a large problem into smaller subproblems, each with a clear purpose, input and result.
- "Add the scores", because it produces the total and the count.
- Any two of: easier understanding, easier checking, reuse of parts, sharing of work.
Sources
- Official BCA syllabus (NEP 2025 scheme), Problem Solving Techniques, course code 25BCA401SEC01, Unit I
