Worksheets › Class 6 › Algorithms: Steps, Order and Debugging › Cheat sheet
Class 6 Algorithms: Steps, Order and Debugging: cheat sheet
CBSE Computational Thinking and AI. 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.
Key ideas
- An algorithm has an input, clear steps in the right order, and an output, and it must finish.
- A number machine does its steps in order; to find the input from the output, undo each step from the end.
- To undo a step, do the opposite: add ↔ take away, multiply ↔ divide.
- Debugging means finding and fixing the mistake; the wrong step is the first one whose result does not follow.
- In a flowchart, Start and Stop are ovals, a process is a rectangle and a yes/no decision is a diamond.
- Swaps and moves on a row of letters must be done one at a time, in the order given.
Remember
| 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 |
Watch out
- Undoing the steps in the same order instead of starting from the last step.
- Marking a later step as wrong when it was done correctly from the mistake before it.
- Reading ≥ as “more than”: it means “more than or equal to”.
Worked example
(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
Practise Algorithms: Steps, Order and Debugging
Revise with this page, then practise: every Algorithms: Steps, Order and Debugging sheet in the app is new, with an answer key and working.
Coming soon for Android and iPhone.