Computational Thinking 🧩
Four habits of mind for breaking big, messy problems down into something a computer — or a person — can actually solve.
🎯 What you'll unlock this lesson
- ✅ Explain each of the four pillars of computational thinking
- ✅ Recognize which pillar is being used in a real scenario
- ✅ Apply all four together to plan a solution to a problem
💡 What is computational thinking?
Computational thinking isn't about computers first — it's a way of thinking about problems that happens to make them easy to hand to a computer afterward. It has four pillars, and real problem-solving usually cycles through all of them.
1.1 Decomposition
Splitting one large, overwhelming problem into several smaller sub-problems that are each easier to tackle on their own — then solving (or assigning) each piece separately.
Example: "plan a class party" breaks into food, music, decorations, and a guest list — four smaller, manageable jobs instead of one huge one.
1.2 Pattern Recognition
Spotting similarities between a new problem and one you've already solved — or between pieces of the same problem — so you can reuse a known approach instead of starting from zero.
Example: noticing that "find the tallest student" and "find the most expensive item" are really the same problem: find the maximum.
1.3 Abstraction
Keeping only the details that matter for the problem at hand and throwing away everything else. A map is a classic example — it keeps roads and landmarks, and abstracts away the exact width of every street.
Example: a train map shows stations and connections in order, not real geographic distance — that detail doesn't matter for the problem "how do I get there."
1.4 Algorithm Design
Writing the exact, ordered, step-by-step instructions that solve the problem — precise enough that someone (or something) with no judgement of their own could follow them and get the right result.
Often drawn as a flowchart before it's ever written as code.
🃏 Key-term flashcards tap to flip
🔀 Flowchart symbols 1.4
Before code, algorithms get drawn. Each shape means something specific — click each one to reveal what it's for.
📋 Worked example: checking if a number is even or odd
| Step | Shape | Instruction |
|---|---|---|
| 1 | Oval | Start |
| 2 | Parallelogram | Input a number, N |
| 3 | Diamond | Is N divided by 2 with no remainder? |
| 4a | Rectangle | Yes → Output "Even" |
| 4b | Rectangle | No → Output "Odd" |
| 5 | Oval | End |
Every flowchart has exactly one Start and at least one End. The diamond is the only shape with two ways out.
Try sketching it yourself first: Input A, B, C → compare A and B → compare the bigger of those to C → output the largest.
| Step | Shape | Instruction |
|---|---|---|
| 1 | Oval | Start |
| 2 | Parallelogram | Input A, B, C |
| 3 | Diamond | Is A > B? |
| 4 | Rectangle | Yes → Max ← A · No → Max ← B |
| 5 | Diamond | Is C > Max? |
| 6 | Rectangle | Yes → Max ← C |
| 7 | Rectangle | Output Max |
| 8 | Oval | End |
🎯 Case study: putting it all together 1.5
Sorting a pile of unordered exam papers into ascending score order uses all four pillars at once:
- 🧩 Decomposition: "sort the whole pile" becomes "repeatedly find the smallest remaining paper and place it next."
- 🔁 Pattern recognition: "find the smallest remaining" is the same small task, repeated.
- 🎭 Abstraction: only the score matters for ordering — ignore the student's name, handwriting, or paper color.
- 📐 Algorithm design: a precise, repeatable procedure — this is selection sort.
🎮 Interactive Selection Sort Visualizer signature move
Hit Step (or Auto-run) to watch the algorithm scan for the minimum, then swap it into place — one pass at a time.
🧮 Trace: sorting [7, 2, 9, 1, 5]
| Pass | Unsorted portion | Minimum found | Swap with | Result |
|---|---|---|---|---|
| 1 | 7 2 9 1 5 | 1 (index 3) | index 0 (7) | 1 2 9 7 5 |
| 2 | 2 9 7 5 | 2 (already first) | — (no swap) | 1 2 9 7 5 |
| 3 | 9 7 5 | 5 (index 4) | index 2 (9) | 1 2 5 7 9 |
| 4 | 7 9 | 7 (already first) | — (no swap) | 1 2 5 7 9 |
Once one element is left, it's automatically in place — the list is sorted.
🎉 Activity 1.1 — Plan the celebration
In groups, plan the running order for a class celebration dance. Fill out a table like this one, applying computational thinking to the planning itself:
| Pillar | Applied to the celebration plan |
|---|---|
| Decomposition | Split into: music selection, formation blocking, costume/prop list, rehearsal schedule |
| Pattern recognition | Reuse last year's formation pattern for the parts of the song that repeat |
| Abstraction | For blocking, only track each dancer's position and timing — ignore costume detail |
| Algorithm design | Write the exact step order: enter → formation 1 → formation 2 → exit, with counts |
🧠 Mini-quiz — no cap, prove it
📝 Exam-style questions try, then peek
- 🧩 Splitting a school project into research, writing, and slides → Decomposition
- 🔁 Noticing two maths problems both reduce to "find the average" → Pattern recognition
- 🎭 A subway map that ignores real distances but keeps station order → Abstraction
- 📐 Writing precise numbered steps to check in a library book → Algorithm design
Pass 1: minimum of [4,1,3] is 1 (index 1) → swap with index 0 → [1,4,3]
Pass 2: minimum of [4,3] is 3 (index 2) → swap with index 1 → [1,3,4]
Result: [1, 3, 4] ✅