Byte by Byte › Book 5: Games, Spreadsheets and Networks › Chapter 1: Computational Thinking and Decomposition
Chapter 1: Computational Thinking and Decomposition
You will learn: the four parts of computational thinking (decomposition, pattern recognition, abstraction and algorithms), how to break a big problem into a tree of smaller ones, and how to use these skills to plan a game.
🌟 The Adventure
The Queen's announcement rolled across Memunic World like thunder. "In three weeks we will hold the first Memunic Games! Every village will compete in sport, and every village will build an arcade game for the Grand Arcade. The Games will be watched by everyone, scored fairly, and kept safe. Simbha, our Guardian, will be in charge."
The crowd cheered. Simbha bowed, and the Queen hung a bronze medallion round his neck: Guardian of the Games.
An hour later Memoon found him in the palace garden, surrounded by scrolls. His mane was sticking out in every direction.
"Memoon," he groaned. "There are tracks to build, games to make, scores to keep, messages to send to twelve villages, gates to guard, judges to choose... I don't know where to start." He gave a small, unhappy roar. Noodles hid behind a bush.
Memoon sat down beside him, opened her notebook and drew one big box in the middle of a fresh page. Inside she wrote: Run the Memunic Games.
"You can't do this," she said. Simbha looked hurt. "Nobody can," she went on. "Not in one go. But you can do a lot of small things. Programmers have a name for what we're about to do. It's called decomposition."
💡 Learn With Memoon
What is computational thinking? Computational thinking is a way of solving problems so that a person, a computer, or both can carry out the solution. It is not about computers only. Engineers, doctors, chefs and event planners use it every day. It has four parts, sometimes called the four pillars.
| Pillar | What it means | Everyday example |
|---|---|---|
| Decomposition | Breaking a big problem into smaller parts that are easier to solve | Cleaning your room becomes: clothes, books, desk, floor |
| Pattern recognition | Spotting things that are the same or similar, so you can reuse a solution | Every maths word problem about speed uses distance ÷ time |
| Abstraction | Keeping the details that matter and ignoring the ones that don't | A metro map shows stations and lines, not every street and tree |
| Algorithms | Writing clear step-by-step instructions to solve the problem | A recipe; the steps to log in to a computer |
You met algorithms in Book 2 and wrote real ones in Scratch in Book 4. This chapter adds the other three.
Decomposition. To decompose a problem, ask: what smaller jobs would have to be done for this to be finished? Write each one down. Then do the same to each smaller job. Keep going until every part is small enough that you know exactly how to do it, or one person can do it in one sitting.
The result looks like an upside-down tree, so it is called a decomposition tree. Here is Memoon's first attempt for the Games:
- Run the Memunic Games
- Sport
- Build the running track
- Make a timetable of races
- Choose fair judges
- Grand Arcade
- Help villages build games
- Set up screens in the arcade hall
- Scores
- Record every result
- Work out totals and winners
- Show the results
- Communication
- Send results between villages
- Send invitations
- Safety
- Guard the gates
- Protect everyone from tricksters
Notice three things. First, the top box is the whole problem. Second, each level is more detailed than the one above. Third, the bottom boxes, called the leaves, are jobs someone can actually start today.
How do you know you have decomposed enough? A part is small enough when you can answer yes to one of these: Do I know exactly how to do this? Could one person or one short program do it? Could I write it as a few steps? If not, break it down again.
Decomposing a game. Programmers decompose before they code. Take a simple game called Catch the Fruit: fruit falls from the top of the screen, and you move a basket left and right to catch it.
- Catch the Fruit
- The basket: move left and right with the arrow keys; stay on screen
- The fruit: start at a random place at the top; fall down; go back to the top when it is caught or reaches the bottom
- Catching: notice when fruit touches the basket
- Score: start at 0; add 1 for each catch
- Ending: stop after 60 seconds; show the final score
Each leaf becomes one small script. That is exactly how you will build games in this book.
Pattern recognition. Once a problem is broken up, look for parts that are alike. In Catch the Fruit, an apple, a banana and a mango all behave the same way: fall, get caught, reset. Solve it once, then reuse the solution. In Chapter 5 you will learn a Scratch tool called clones that does exactly this. Patterns also show up between problems: almost every game has a player, something to collect or avoid, a score and an ending.
Abstraction. Abstraction means hiding detail that does not matter for this problem. A metro map is a famous example. It shows stations, lines and where you change trains, but the bends of the track, the buildings above and the real distances are left out. For a passenger, those details would only get in the way.
In a game, the basket does not need a real weight or a real material. It only needs a position, a size and a way to move. The fruit does not need vitamins. Programmers ask: what does my program need to know about this thing? and ignore the rest. When you choose which details to keep, you are abstracting.
Putting the four together. Computational thinking usually happens in this order:
- Decompose the problem into parts.
- Recognise patterns among the parts, and with problems you have solved before.
- Abstract: decide which details each part really needs.
- Write an algorithm for each part, then turn it into code.
Order and dependencies. Some parts must be done before others. You cannot show the results before you record them. You cannot test catching before the fruit falls. A part that has to wait for another part depends on it. When you plan, number your leaves in an order that respects these dependencies.
💡 Memoon’s tip: If a problem feels scary, it is usually because you are looking at the top box. Look at the leaves instead.

✍️ Try It Yourself
Activity 1: Decompose a class picnic. In your notebook, draw a decomposition tree for Organise a class picnic. Use at least three levels. Your second level might include food, place, travel, games and permission. Break each into at least two leaves. Then:
- Circle any leaf you still don't know how to do, and break it down one more level.
- Number the leaves in the order they must happen. Which leaves depend on others?
- Put a star next to leaves that could be done at the same time by different people.
Activity 2: Decompose a real game. Open scratch.mit.edu and click Explore. Choose any simple game and play it for two minutes. Do not look inside yet. In your notebook, decompose it like Catch the Fruit above: the player, the other objects, how they interact, the score and the ending. Then click See Inside and check: did each part of your tree become a script or a group of scripts?
Activity 3: Pattern hunt. Think of three games you know (on a computer, a phone or a board). For each one, write: Who is the player? What do you collect or avoid? How do you score? How does it end? Underline anything that is the same in all three. That shared shape is a pattern you can reuse.
Unplugged: The abstraction map. Draw a map of your route from home to school (or to a park) that a new friend could follow. You may use only ten labels. Which details did you keep? Which did you leave out? Swap maps with someone and see if they can follow yours.
🎉 Memoon Solves It
By sunset the scrolls were gone. In their place was one large tree pinned to a board in the palace garden. Each branch had a friend's name beside it.
"Kachui, you're good with order and timetables: Sport is yours," said Memoon. "Beautine, you can help the villages with the Grand Arcade. Nimo, you're good with numbers: Scores. Bleep, Communication. And Simbha..." She tapped the last branch. "Safety. You're the Guardian. That's the part only you can do."
Simbha studied the tree. "Every leaf is something I can start tomorrow," he said slowly. His mane seemed to settle by itself.
"And look," said Memoon, pointing. "The Arcade games, the Scores and the Sport results all need the same thing: something that remembers numbers and changes them. That's a pattern. If we learn it once, we can use it everywhere."
"What is it called?" asked Simbha.
Memoon wrote one word at the top of a new page: Variables.
❓ Check Your Knowledge
- Name the four pillars of computational thinking.
- What is decomposition? Give an example from your own life.
- In a decomposition tree, what are the bottom boxes called, and what should be true about them?
- Match each pillar to its example: (a) a metro map; (b) a recipe; (c) noticing that apples, bananas and mangoes all fall the same way in a game; (d) splitting clean my room into four jobs.
- True or false: computational thinking is only useful for people who write code.
- What does it mean for one part of a plan to depend on another? Give an example from Catch the Fruit.
- Fill in the blank: abstraction means keeping the details that ________ and ignoring the ones that don't.
- Why do programmers decompose a game before they start coding?
- Challenge: Draw a three-level decomposition tree for Make a two-minute animated birthday card in Scratch. Mark one pattern you notice and one detail you would abstract away.
📚 Word Bank
- Computational thinking: a way of solving problems so that a person or a computer can carry out the solution.
- Decomposition: breaking a big problem into smaller, easier parts.
- Decomposition tree: a diagram showing a problem broken into smaller and smaller parts.
- Leaf: a bottom box in a decomposition tree; a job small enough to start.
- Pattern recognition: spotting similarities so a solution can be reused.
- Abstraction: keeping important details and hiding unimportant ones.
- Algorithm: a clear, step-by-step set of instructions to solve a problem.
- Dependency: when one task must wait for another to be finished first.
Keep learning with Byte by Byte
Explore Book 5: Games, Spreadsheets and Networks. Find the ebook, purchase details and teaching slides on MemuniCity.
Comments
Post a Comment