Computer Science Fundamentals · Foundations

Algorithms

Want it in plain words first? Jump to Eli explains — the same idea, no jargon.
On this page 9 sections
  1. In 30 seconds
  2. Why this matters
  3. The college version
  4. Eli explains
  5. Worked example
  6. Key takeaway
  7. Quick check
  8. Study tools
  9. Sources & references

In 30 seconds

An is a finite, well-defined, step-by-step procedure that turns some into a desired . It is the recipe, not the meal: a plan you could hand to any careful follower and get the same result. Knuth pins down five properties every algorithm has - , , , input, and output - and the same problem can usually be solved by several different algorithms.

Why this matters

Every program you will ever write or use rests on algorithms, so learning to think in clear, finite, unambiguous steps is the skill that makes the rest of computer science possible. Being able to describe a procedure precisely - and to notice when two procedures solve the same problem with very different amounts of work - lets you reason about correctness before you touch a keyboard and compare designs before you commit to one. Outside programming, the same discipline sharpens how you write instructions, break down messy tasks, and judge whether a set of directions will actually finish and give the right answer.

The college version

What counts as an algorithm

An algorithm is a finite, well-defined sequence of steps that transforms input into output. NIST's Dictionary of Algorithms and Data Structures puts it compactly as a computable set of steps to achieve a desired result. Two words in that sentence do a lot of work. 'Finite' means the procedure has to stop - a list of steps that could run forever is not an algorithm. 'Well-defined' means each step is spelled out clearly enough that following it leaves no room for guessing. An algorithm is abstract: it is the method itself, independent of any programming language, machine, or person carrying it out. The word traces back to the ninth-century Persian mathematician al-Khwarizmi, whose treatise on arithmetic circulated in Latin as 'Algoritmi de numero Indorum'; Europeans turned the Latinized 'Algoritmi' into our modern 'algorithm.' Long before computers, the idea already meant a reliable step-by-step recipe for getting an answer.

Knuth's five properties

In The Art of Computer Programming, Donald Knuth lists five properties that a genuine algorithm must have, and they are worth memorizing because they double as a checklist. Finiteness: the algorithm must always terminate after a finite number of steps. Definiteness: each step must be precisely and unambiguously defined, so there is exactly one thing to do at each point. Effectiveness: every operation must be basic enough that it can, in principle, be carried out exactly - a step like 'now guess the best answer' is not effective. Input: zero or more quantities are supplied before the algorithm begins, taken from specified sets of values. Output: one or more quantities come out, standing in a specified relationship to the input. A procedure that skips any of these is something weaker - a heuristic, a vague guideline, or a program that might hang. When you evaluate a set of steps, run them against these five and the gaps usually jump out.

Four ways to express the same procedure

The same algorithm can be written down in several forms, and choosing among them is a trade between how easily a human reads it and how directly a machine can run it. Natural language describes the steps in plain, deliberately precise sentences - closer to a recipe than to prose - which is readable but easy to make ambiguous. A draws each operation as a labeled block and uses arrows to show the order and the branches, which makes control flow visual. looks like a high-level programming language but is language-independent and is not meant to be run directly; it strips away syntax so you can focus on the logic. Code is the algorithm made executable in a specific language, at the cost of that language's rules and quirks. All four can capture one and the same procedure. Notice that the exact conventions of pseudocode are their own subject; here the point is only that expression and algorithm are separate - a good algorithm survives translation between all four forms.

One problem, many algorithms

A crucial early realization is that a problem and an algorithm are not the same thing. 'Sort these names alphabetically' is a problem; there are many different, all-correct algorithms that solve it, and they can differ enormously in how much work they do on large inputs. This is why 'correct' is only the first question. Once you have two algorithms that both produce the right answer, you compare them on - roughly, how their running time or memory use grows as the input grows. That growth-rate analysis has its own vocabulary and its own topic (time complexity and Big-O), so this lesson only flags that the comparison exists rather than carrying it out. The habit to build now is to separate three questions and ask them in order: does the procedure finish, does it always give the right answer, and only then, how efficient is it? Specific searching and sorting algorithms are studied in their own lessons; they are simply well-known algorithms for well-known problems.

Eli, the EliExplains learning guide

Eli explains

The same idea, in plain words

Explain it like I’m 10

An algorithm is a set of instructions clear enough that anyone who follows them exactly gets the same right answer, and the instructions always come to an end. Every step has to make sense on its own ('add these two numbers'), not leave you guessing ('pick a good number'). It needs something to start with, it gives something back, and it can never loop forever. The instructions are separate from how you write them down - you can say them out loud, draw them as boxes and arrows, sketch them in shorthand, or type them as real code, and it is still the same algorithm underneath.

Picture it like this

An algorithm is like a recipe. A recipe takes ingredients (the input), gives you step-by-step directions anyone can follow, and ends with a finished dish (the output). Each step is exact - 'bake at 350 degrees for 20 minutes,' not 'bake until it feels right' - and the recipe stops rather than going on forever. And just as two cooks can reach the same dish by different recipes, one problem can have several correct algorithms.

Where the picture stops working

The recipe picture leaks in a few places. A recipe tolerates vagueness ('salt to taste') that a real algorithm forbids - every step must be exact. Recipes never loop or branch the way algorithms do ('repeat until the list is empty; if the number is bigger, keep it'). And recipes are not usually compared for efficiency, whereas comparing how much work competing algorithms do is central to computer science.

Worked example

Problem: find the largest number in the list [3, 9, 2, 7, 5]. Algorithm (linear scan): set 'largest' to the first element, then walk through the rest, replacing 'largest' whenever you meet a bigger value. Trace: largest starts at 3. Compare 9 > 3? Yes, largest becomes 9. Compare 2 > 9? No. Compare 7 > 9? No. Compare 5 > 9? No. The scan ends and returns 9. That is four comparisons for five elements - in general n-1 comparisons for n elements, one per element after the first. Two details make this a real algorithm: it is finite (it stops after the last element) and definite (each comparison has one clear outcome). It also needs a guard for the empty list, where there is no 'first element' to start from. This procedure was executed and traced in Python to confirm it returns 9, matching the built-in maximum, and that it handles single-element and all-negative lists correctly.

Key takeaway

An algorithm is a finite, well-defined, step-by-step procedure that turns input into output - satisfying Knuth's five properties (finiteness, definiteness, effectiveness, input, output) - and the same problem usually has several correct algorithms that differ in efficiency.

Quick check

3 questions here, of 5 in this lesson’s practice set. Answers stay hidden until you check.

Question 1 of 3foundational

Which statement best defines an algorithm?

Choose an answer, then check it.
Question 2 of 3foundational

Which of the following is NOT one of Knuth's five required properties of an algorithm?

Choose an answer, then check it.
Question 3 of 3foundational

Which of these is a standard way to express an algorithm before writing it in a real programming language?

Choose an answer, then check it.
Practice all 5

Keep learning

Ready to build on this? Continue to the next lesson.

Practice this lesson
Study tools & related lessonsYou’ll learn to · Common mistakes · Easily confused · Key vocabulary · Related

You’ll learn to

  • Define an algorithm as a finite, well-defined procedure that transforms input into output.
  • List and explain Knuth's five properties: finiteness, definiteness, effectiveness, input, and output.
  • Distinguish the four common ways to express an algorithm: natural language, pseudocode, flowcharts, and code.
  • Explain why one problem can have multiple correct algorithms that differ in efficiency.
  • Apply a linear-scan algorithm to find the maximum of a list and trace its steps.

Common mistakes

  • Treating 'algorithm' and 'computer program' as the same thing.

    An algorithm is the abstract procedure; a program is that procedure implemented in a particular language. The same algorithm can be written in Python, Java, pseudocode, or a flowchart and stays the same algorithm.

  • Believing a set of steps is an algorithm even if it might never stop.

    Finiteness is required. A procedure that can loop forever on some input is not an algorithm; it must always terminate after a finite number of steps.

  • Writing steps like 'choose the best option' or 'sort it somehow' and calling them algorithmic.

    Definiteness and effectiveness are required. Each step must be precise and basic enough to carry out exactly, with no guessing about what to do next.

  • Assuming a problem has only one algorithm, or that any correct algorithm is as good as any other.

    Most problems admit many correct algorithms, and they can differ hugely in efficiency. Correctness comes first, but comparing efficiency is why algorithm design matters.

  • Thinking you must find the maximum by first sorting the list.

    A single linear scan finds the maximum in n-1 comparisons without sorting. Sorting does more work than the problem requires.

Easily confused

Algorithm vs. Program

An algorithm is a language-independent procedure for solving a problem; a program is one concrete implementation of an algorithm in a specific programming language. One algorithm, many possible programs.

Definiteness vs. Effectiveness

Definiteness means each step is unambiguously specified (you know exactly what to do); effectiveness means each step is basic enough to actually be done exactly. A step can be perfectly clear yet not effective, like 'output the largest prime number.'

Pseudocode vs. Code

Pseudocode is a readable, language-independent sketch of the logic that is not meant to run; code is executable in a specific language with its full syntax. Both can express the same algorithm.

Correctness vs. Efficiency

Correctness asks whether an algorithm always gives the right answer and terminates; efficiency asks how much time or memory it uses. An algorithm must be correct first, and only among correct algorithms does comparing efficiency make sense.

Key vocabulary

Algorithm
A finite, well-defined sequence of steps that transforms input into output; a computable procedure for achieving a specified result, independent of any language or machine.
Finiteness
The property that an algorithm always terminates after a finite number of steps rather than running forever.
Definiteness
The property that every step of an algorithm is precisely and unambiguously specified, leaving no room for interpretation.
Effectiveness
The property that each operation is basic enough to be carried out exactly, in principle by a person with paper and pencil.
Input
The zero or more quantities supplied to an algorithm before it begins, drawn from a specified set of values.
Output
The one or more quantities an algorithm produces, standing in a specified relationship to its input.
Pseudocode
A language-independent, human-readable outline of an algorithm that resembles a programming language but is not meant to be executed directly.
Flowchart
A diagram that expresses an algorithm as labeled operation blocks connected by arrows showing the order and branching of steps.
Efficiency
A measure of how much time or memory an algorithm uses, typically judged by how that cost grows as the input size grows.

Sources & references

  1. algorithm — Dictionary of Algorithms and Data Structures (DADS) — U.S. National Institute of Standards and Technology (NIST)
  2. The Art of Computer Programming, Volume 1: Fundamental Algorithms (Section 1.1) — Donald E. Knuth (Addison-Wesley)
  3. Flowcharts and Pseudocode - CC 310 Textbook — Kansas State University, Department of Computer Science
  4. Muhammad ibn Musa al-Khwarizmi - MacTutor History of Mathematics Archive — University of St Andrews (School of Mathematics and Statistics)

EliExplains lessons are original prose written from the open, credible references above. See Copyright & Licensing.

Researched 2026-08-19

Educational content only. It is not medical, legal or professional advice. Found an error? Tell us.