Read the first worked example with the solution open so the structure is clear.
Try the practice problems before revealing each solution.
Use the related concepts and background knowledge badges if you feel stuck.
What to Focus On
Core idea:Solve each small independent part, then combine the solutions into a complete answer.
Common stuck point:The parts must be truly independent or have clear dependencies.
Sense of Study hint:To decompose a problem, first identify the major tasks or components involved. Then ask for each part: can this be solved on its own? If a part is still too complex, decompose it further. Finally, determine how the solved parts connect back together.
Common Mistakes to Watch For
Before you work through the examples, skim the mistake guide so you know which shortcuts and
sign errors to avoid.
Step 1: Identify the major areas: events/activities, equipment, scheduling, participants, venue.
Full solution
2
Step 2: Break each area down further โ e.g., Events: choose sports, set rules, assign referees. Scheduling: set times, allocate fields, plan breaks.
3
Step 3: Each sub-problem is now small enough to tackle individually.
Decomposition breaks a complex problem into smaller, manageable parts. Each part can be solved independently, making the overall problem less overwhelming.
Example 2
medium
Decompose the task of building a simple calculator program.
Example 3
medium
Decompose 'compute 5!=5ร4ร3ร2ร1' into sub-steps.
Example 4
medium
Decompose 'check if a year (e.g. 2020) is a leap year' into the rule: divisible by 4 AND (not divisible by 100 OR divisible by 400). Apply to 2020.
Example 5
hard
Decompose 'compute 52+122โ' into sub-tasks. Give the result.
Example 6
hard
A robot task decomposes into: pick up (3 s), move (5 s), place (2 s). With 4 robots doing 20 identical tasks each in parallel, what is the wall-clock time?
Example 7
challenge
Decompose '1+2+โฆ+100' using Gauss's pairing trick: pair 1+100, 2+99, etc. How many pairs and what is the total?
Example 8
challenge
A problem decomposes into 4 parts taking 3, 5, 7, and 2 minutes. Parts 1, 2, 3 are independent; part 4 needs all of them. With 3 workers, what is the minimum total time?Parallel phase: max(3,5,7) = 7 min. Then Part 4: +2 min. Total = 9 minutes.
Practice Problems
Try these problems on your own first, then open the solution to compare your method.
Example 1
easy
Decompose the problem of creating a sandwich into at least 4 sub-tasks.
Example 2
medium
Decompose building a class voting app into four modules, and identify one dependency between them.
Example 3
easy
To build a sandwich-making program you split it into: get bread, add filling, close sandwich. This splitting of one task into smaller tasks is called what?
Example 4
easy
A program is split into sub-problems P1โ,P2โ,P3โ. After solving each, what must you still do to finish?Decomposition flow: after solving all parts, the sub-solutions must be combined.
Example 5
easy
Which is a GOOD decomposition of 'plan a party': (a) ['do everything'], (b) ['send invites','buy food','set up venue']?
Example 6
easy
True or false: in decomposition, the sub-problems should ideally be solvable independently of each other.
Example 7
easy
Decompose 'compute the average of a list' into two sub-tasks. Name them.
Example 8
easy
A task is split into 50 tiny one-line parts that are hard to reconnect. What decomposition mistake is this?
Example 9
easy
To search a phone book, you split it in half and search one half. Splitting the problem into a smaller version of itself is which technique?
Example 10
easy
Which task is a sub-problem of 'send an email': (a) authenticate user, (b) bake a cake?
Example 11
medium
You decompose 'grade a quiz' into: (1) read answers, (2) compare to key, (3) total the score. If step 3 needs results from step 2, which steps are independent of each other?Steps 2 and 3 form a chain; Step 1 is the independent step.
Example 12
medium
A program decomposes into modules A, B, C where C combines A's and B's outputs. Express the final solution S in terms of sub-solutions.The final solution S = f(Sโ, S_b) is assembled by C from the outputs of modules A and B.
Example 13
medium
Decompose computing a2+b2โ for a=3,b=4 into sub-tasks and give the result.
Example 14
medium
To process 1,000 files you decompose into 4 independent batches of 250. If batches run in parallel, what is the main benefit of this decomposition?
Example 15
medium
A recipe app decomposes 'cook dinner' into appetizer, main, dessert. The dessert needs the oven the main is using. What kind of hidden problem does this reveal?
Example 16
medium
Decompose 'is 2024 a leap year' into sub-checks: divisible by 4? by 100? by 400? Apply the rule and answer.
Example 17
medium
A team splits a project so each member owns one module, but two members both edit the login module. What decomposition principle was violated?
Example 18
medium
Decompose 'reverse a 4-letter word WXYZ' into swaps: swap positions 1&4, then 2&3. After applying to 'CODE', what is the result?
Example 19
medium
To validate a password you decompose into: length>=8, has a digit, has a letter. For 'abc12345' (8 chars, has digits and letters), does it pass all sub-checks?
Example 20
challenge
You must compute the total area of an L-shaped region. Show how decomposition gives a clean approach, using a 6x4 rectangle and a 2x3 rectangle.
Example 21
challenge
Merge sort decomposes a list, sorts halves, then merges. For [5,2,8,1] split into [5,2] and [8,1], sort each and merge. Show the result.
Example 22
challenge
A problem decomposes into parts taking 4, 7, and 5 minutes. Parts 1 and 2 are independent; part 3 needs both. With two workers, what is the minimum total time?
Example 23
easy
What is the main goal of decomposition?
Example 24
easy
Decompose 'wash dishes' into three sub-tasks.
Example 25
easy
Which is a BETTER decomposition of 'cook spaghetti': (a) ['cook spaghetti'], (b) ['boil water','add pasta','drain','plate']?
Example 26
easy
Decompose 'compute the mean of [4,6,8]' into two sub-tasks.
Example 27
easy
Decompose 'compute the perimeter of a rectangle with sides 5 and 7'.
Example 28
medium
You decompose 'process 8000 records' into 4 equal batches. How many records per batch?
Example 29
medium
Tasks A and B take 6 min each independently; C takes 4 min and needs A and B done. With two workers, what is the minimum total time?A and B run in parallel (wall time 6 min), then C adds 4 min โ minimum total is 10 minutes.
Example 30
medium
Decompose 'is 360 divisible by 12' into the two sub-checks: divisible by 4 AND divisible by 3. Apply both.
Example 31
medium
A program has modules A, B, C where C needs A's output but B is independent. Which modules can run in parallel?
Example 32
medium
You decompose 'compute area of an L-shape' as a big 8ร5 rectangle minus a small 3ร2 corner. Compute the area.
Example 33
medium
A class project of 12 hours is decomposed into 4 equal independent parts assigned to 4 students working in parallel. What is the wall-clock time?
Example 34
medium
Decompose 'reverse the string CODE' as two swaps: positions 1<->4 and 2<->3. Apply.
Example 35
hard
Decompose merge sort on [4,1,3,2]: split into [4,1] and [3,2], sort each, then merge. Show the final list.
Example 36
hard
You decompose 'detect duplicates in a list' as: sort, then scan adjacent pairs. For [3,1,4,1,5,9,2,6,5,3], how many duplicate values does this approach find?
Example 37
hard
Two members both edit the same file in a 4-module project. Which decomposition principle is violated?
Example 38
hard
Decompose 'validate password' as: length>=8, has uppercase, has digit. For 'Cat12345' (8 chars, includes C, includes digits), does it pass all sub-checks?
Example 39
challenge
A pipeline has stages A (4 ms), B (8 ms), C (5 ms). What is the throughput-limiting stage and the throughput in tasks per second?