An algorithm is a clear, step-by-step set of instructions. We follow steps in order, run them backwards, and debug the step that is wrong.
| Forwards | 5 → add 3 → 8 → multiply by 4 → 32 |
| Backwards | 32 → divide by 4 → 8 → take away 3 → 5 |
| Flowchart shapes | oval: start/stop; rectangle: process; diamond: decision |
| Pass rule | “if mark ≥ 40” includes a mark of exactly 40 |
| Pseudocode | steps written in simple sentences close to code |
(a) Put the steps to find the larger of two numbers in the right order (write the letters): (a) Read the second number (b) Write down the larger one (c) Read the first number (d) Compare the two numbers
(b) Sana starts with 20 and follows these steps, writing the number after each one:
Step 1: take away 6 (Sana writes 14)
Step 2: multiply by 4 (Sana writes 56)
Step 3: take away 3 (Sana writes 53)
Step 4: multiply by 2 (Sana writes 116)
One step was worked out wrongly, and the later steps were done correctly from it. Which step number is wrong?
Working: (a) Read the first number → Read the second number → Compare the two numbers → Write down the larger one; (b) step 4 should give 106, not 116
Answer: (a) c, a, d, b; (b) 4