MCS-211 ยท Unit 1
Basics of an Algorithm and its Properties
What an algorithm is, its five essential properties, how to write one, and how to judge whether it is efficient.
What is an algorithm?
An algorithm is a finite, step-by-step set of clear instructions that takes some input and produces the required output to solve a problem.
Think of a recipe: it lists ingredients (input), gives exact steps in order, and ends with a dish (output). An algorithm does the same for a computational problem.
Five properties of a good algorithm
| Property | Meaning |
|---|---|
| Input | Takes zero or more well-defined inputs. |
| Output | Produces at least one output that solves the problem. |
| Definiteness | Every step is precise and unambiguous. |
| Finiteness | It must stop after a finite number of steps. |
| Effectiveness | Each step is basic enough to be carried out exactly, in finite time. |
Exam tip: "List and explain the properties of an algorithm" is a frequently asked short question. Learn all five with one-line examples.
Example: finding the largest of n numbers
Algorithm Largest(A, n)
1. max โ A[1]
2. for i โ 2 to n do
3. if A[i] > max then
4. max โ A[i]
5. return max
- Input: an array
Aofnnumbers - Output: the largest value
- The loop runs
n โ 1times, so the running time grows linearly withn. We write this as O(n).
Ways to express an algorithm
- Natural language โ plain English steps; easy to read but can be ambiguous.
- Flowchart โ a diagram using standard symbols; good for simple logic.
- Pseudocode โ structured, programming-like text; the most common form in exams.
- Programming language โ an actual implementation, for example in C.
Why analyse algorithms?
The same problem can often be solved in several ways. Analysis helps us compare them by:
- Time complexity โ how running time grows as the input size grows.
- Space complexity โ how much extra memory is needed.
We usually focus on the worst case, because it gives a guarantee that the algorithm will never be slower than that.
Quick revision
- An algorithm is a finite sequence of unambiguous steps.
- Five properties: input, output, definiteness, finiteness, effectiveness.
- Pseudocode is the preferred way to write algorithms in answers.
- Efficiency is measured by time and space complexity, usually in the worst case.
Original notes by NotesMitra ยท Updated 29 Nov 2026
Report a problem