What is an Algorithm?
An algorithm is a finite, precise sequence of unambiguous steps that solves a problem. It must be finite (it terminates), definite (each step is clear), and effective (each step is doable).
Computational thinking is the mindset behind algorithm design. Its core habits:
| Habit | What it means |
|---|---|
| Decomposition | Break big problems into subproblems |
| Pattern recognition | Spot repeated structures |
| Abstraction | Hide irrelevant detail |
| Algorithm design | Express solution as steps |
Before coding, use pseudocode (language-independent English) or flowcharts to plan logic.
How to Compute vs What It Is
A mathematical definition states what an answer is, but an algorithm gives a concrete procedure for computing it.
| Concept | Role | Example |
|---|---|---|
| Definition | What the answer is | "Largest common divisor" |
| Algorithm | How to compute it | Euclid's GCD method |
Common pitfall: Confusing a specification with an algorithm. Saying "prime factorisation is the unique product of primes" only specifies the answer; you still need a terminating procedure like trial division to produce it.