Lesson 2 · Computational Thinking
Order matters — the make-a-sandwich algorithm.
Socks, then shoes. Shoes, then socks.
Same two steps. Same words. One of them works and the other leaves you hopping around looking ridiculous.
In an algorithm, the order of the steps is part of the instruction. Change the order and you have changed what the algorithm does — often into something that fails completely.
Here is a real algorithm with its steps out of order. Watch it fail:
| Order given | Step | What happens |
|---|---|---|
| 1 | Pour the tea into a cup | Cup gets nothing — no tea made yet |
| 2 | Boil the water | Water boils, alone |
| 3 | Add tea leaves | Leaves go into the pot |
| 4 | Drink | You drink an empty cup |
Every step is correct on its own. The sequence is what's broken — and that is one of the most common bugs there is.
The classic exercise, done carefully. You're writing steps for someone who has never seen a sandwich, so nothing can be assumed.
Brain-dump everything needed to make a jam sandwich. Don't worry about order yet — just get every action onto paper.
In the algorithm: (1) open jam jar, (2) take out bread, (3) spread jam on bread, (4) close jar — which two steps could safely swap places?
This chapter is free — open this lesson in your portal to save your answers and track progress.
Write a 6–8 step algorithm for something you do often — packing your school bag, charging your phone, making a video call.
Now scramble the order and hand it to a partner. Can they put it back correctly? Ask them which steps they were sure about and which were guesses.
If step B needs the result of step A, their order is locked — never move them. If they don't touch each other, the order is loose. Spotting loose steps is how computers run many things at the same time and finish faster.
Write your full morning routine from waking up to leaving the house — at least ten steps.
Then mark each step L (locked: it must come after the step before it) or F (free: it could move).
Finally: if you could do all the free steps at the same time, how much faster could your morning be?