Practice Decomposition in CS Thinking

Use these practice problems to test your method after reviewing the concept explanation and worked examples.

Quick Recap

Breaking a complex problem into smaller, independently-solvable parts that combine into a complete solution.

Decomposition is how a pizza shop handles a big order: one person makes the dough, one adds sauce and toppings, one runs the oven, and one boxes the pizzas. Each job can be done well by itself, and the jobs fit together at the end. If the jobs get too tiny, like one person per topping, passing the pizza around takes longer than making it.

Showing a random 20 of 50 problems.

Example 1

easy
Decompose 'compute the mean of [4,6,8]' into two sub-tasks.

Example 2

easy
A task is split into 50 tiny one-line parts that are hard to reconnect. What decomposition mistake is this?

Example 3

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 4

easy
Which task is a sub-problem of 'send an email': (a) authenticate user, (b) bake a cake?

Example 5

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 6

easy
True or false: after decomposition, you still need to combine the sub-solutions.

Example 7

easy
A program is split into sub-problems P1,P2,P3. After solving each, what must you still do to finish?

Example 8

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 9

easy
Decompose 'compute the average of a list' into two sub-tasks. Name them.

Example 10

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 11

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 12

easy
True or false: in decomposition, the sub-problems should ideally be solvable independently of each other.

Example 13

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?

Example 14

easy
You need to plan a school sports day. Decompose this problem into smaller sub-problems.

Example 15

medium
Decompose 'is 360 divisible by 12' into the two sub-checks: divisible by 4 AND divisible by 3. Apply both.

Example 16

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 17

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 18

medium
You decompose 'process 8000 records' into 4 equal batches. How many records per batch?

Example 19

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 20

medium
Decompose 'is 2024 a leap year' into sub-checks: divisible by 4? by 100? by 400? Apply the rule and answer.