Thinking in steps
About 25 minutes · read, practise, then check your understanding
Programming is mostly thinking, then typing. Interviewers ask you to explain your approach before you code, and most beginner bugs are missing or wrongly ordered steps.
You will learn
- What an algorithm is
- How to break a problem into exact steps
- How to find missing steps and unusual cases (edge cases)
Before you start
- None. No computer needed for this lesson.
The idea, simply
An algorithm is a list of exact steps that solves a problem. A computer follows steps perfectly but understands nothing, so the steps must leave no room for guessing.
Good steps have three qualities: each step does one thing, the order is correct, and they say what to do when something unusual happens.
Understand the goal
Say in one sentence what the finished result is.
List the inputs
What do you start with? Numbers, a list, a name?
Write the steps
One action per line, in order.
Test with examples
Follow your own steps with real values, like a computer would.
Find edge cases
What if the list is empty, the number is zero, or the input is wrong?
See it in action
Problem: find the highest mark in a list of marks.
1. If the list is empty, say "no marks" and stop.
2. Set highest to the first mark.
3. For each remaining mark:
3a. If the mark is greater than highest, set highest to that mark.
4. Say highest.Common mistakes
- Writing vague steps like 'process the data'.
- Break it down until each step is one clear action.
- Only testing the happy path.
- Always try empty, zero, very large and wrong inputs.
Key takeaways
- An algorithm is exact steps; computers cannot guess.
- Test steps by hand with real values.
- Handle edge cases explicitly.

