🎓 Prepared by students from Boğaziçi University

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.

Short answer

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.

Algorithm: find the largest number in a list
  1. 1
    Start
    Set max = first element of the list
  2. 2
    Compare
    Look at the next element in the list
  3. 3
    Update
    If it is bigger than max, replace max with it
  4. 4
    Repeat
    Go back to Compare until the list ends
  5. 5
    Return
    Output max as the answer
01

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]
02

Flashcards

03

Quick quiz

Q1.Which best defines an algorithm?

Correct answer: B. An algorithm is a finite, well-defined sequence of steps — it's independent of any specific language or machine.

Q2.Why must an algorithm be finite?

Correct answer: B. If an algorithm never stops, it never produces a result — finiteness (termination) is a core requirement.

Q3.Which of these is NOT a property of a well-designed algorithm?

Correct answer: C. Good algorithms are deterministic and predictable; unwanted randomness undermines correctness.

Q4.What is pseudocode used for?

Correct answer: B. Pseudocode is a language-independent way to plan and communicate an algorithm before implementation.
📄Download this topic as a printable worksheet (PDF)Summary + 10 questions + answer key — print it, share it in class.
Study better with Bounlu apps
Notek
Notek

The full card deck, worked steps and AI-tutor support for “What is an Algorithm?” are in Notek — study by hand before your exam.

Get it free
Notek 1Notek 2Notek 3Notek 4Notek 5
04

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.

05

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.

Related topics