What is an Algorithm?
An algorithm is a finite, well-defined sequence of steps that turns an input into a desired output. From sorting a list of numbers to routing a GPS, algorithms are the recipes computers follow to solve problems.
An algorithm is a step-by-step procedure for solving a problem or completing a task in a finite number of clearly defined instructions. A good algorithm is correct, finite, and efficient.
- 1↓StartSet max = first element of the list
- 2↓CompareLook at the next element in the list
- 3↓UpdateIf it is bigger than max, replace max with it
- 4↓RepeatGo back to Compare until the list ends
- 5ReturnOutput max as the answer
Step-by-step worked examples
Trace the 'find the maximum' algorithm on [4, 9, 2, 7].
max = 4 (first element) Compare 9 > 4 → max = 9 Compare 2 > 9? No → max stays 9 Compare 7 > 9? No → max stays 9 Result: max = 9
Use linear search to find 7 in [5, 3, 7, 1, 9].
Check index 0: 5 ≠ 7 Check index 1: 3 ≠ 7 Check index 2: 7 = 7 → found! Result: index 2
One pass of bubble sort on [5, 1, 4].
Compare 5 and 1: 5 > 1 → swap → [1, 5, 4] Compare 5 and 4: 5 > 4 → swap → [1, 4, 5] End of pass, list is more sorted: [1, 4, 5]
Flashcards
Quick quiz
Q1.Which best defines an algorithm?
Q2.Why must an algorithm be finite?
Q3.Which of these is NOT a property of a well-designed algorithm?
Q4.What is pseudocode used for?
The full card deck, worked steps and AI-tutor support for “What is an Algorithm?” are in Notek — study by hand before your exam.
Common mistakes
Thinking an algorithm must be written in code. — Correct: An algorithm is language-independent — it can be plain English, pseudocode, or a flowchart before it's ever coded.
Believing any sequence of steps counts, even if it never ends. — Correct: A true algorithm must be finite — it has to terminate and produce an output.
Assuming faster code always means a better algorithm. — Correct: Efficiency matters, but correctness comes first — a fast wrong answer is still wrong.
Confusing an algorithm with the problem it solves. — Correct: The problem is the 'what'; the algorithm is the 'how' — the specific method used to solve it.
FAQ
What is an algorithm?
An algorithm is a finite, ordered sequence of clearly defined steps that transforms an input into an output to solve a specific problem.
What are the main types of algorithms?
Common types include sorting (e.g., bubble sort), searching (e.g., binary search), recursive, greedy, divide-and-conquer, and dynamic programming algorithms.
What are some everyday algorithm examples?
A recipe, GPS route directions, a phone's autocomplete, and sorting contacts alphabetically are all algorithms in daily life.
How do you evaluate an algorithm's efficiency?
By analyzing its time and space complexity, usually expressed with Big-O notation, which describes how runtime grows with input size.




