What Are the 3 Requirements of an Algorithm?

The three requirements of an algorithm are finiteness, definiteness, and defined input and output. Finiteness means the steps end. Definiteness means each step has exactly one meaning. Input and output means the algorithm takes zero or more inputs and produces at least one output. Most textbooks extend this to five criteria by adding effectiveness and by counting input and output separately. That five-item list is the one to memorize for an exam.

The Five Criteria of an Algorithm

Donald Knuth set out the standard list in The Art of Computer Programming, and almost every data structures course repeats it.

CriterionWhat it requiresOne-line test
InputZero or more values given before the steps beginCan you name what goes in?
OutputAt least one value that relates to the inputCan you name what comes out?
DefinitenessEvery step is exact and has one meaningCould two people follow it and act differently?
FinitenessThe steps end after a finite number of operationsIs there a valid input on which it never stops?
EffectivenessEach step is basic enough to be done exactly, by hand, in finite timeDoes any step say "somehow" or "guess"?

The short answer of three comes from grouping input and output together and treating effectiveness as part of definiteness. The five-item version is the safer answer, because it covers both framings.

Finiteness

An algorithm must stop. A procedure that runs forever on some valid input is not an algorithm, even if every step is precise. The usual proof of finiteness is a quantity that gets smaller on every pass and cannot go below a bound. In a loop over a list of n items, the number of unvisited items falls by one each time and reaches zero after n steps.

Finiteness is a promise about every valid input, not the typical one. A search that stops when it finds the target still needs a rule for when the target is absent. Without that rule the procedure fails the criterion.

Definiteness

Each step must mean exactly one thing. "Pick a large number" is not definite. "Set max to the first element" is. Definiteness is what lets a computer, which cannot ask what you meant, carry out the steps. It is also why pseudocode uses fixed words such as if, for each, and return rather than free prose.

A related term is unambiguous. It means the same thing, and exam questions use the two words interchangeably.

Input and Output

An algorithm has zero or more inputs and at least one output. The zero is real: an algorithm that prints the first 100 primes takes no input. The at least one output is firm: a procedure that produces nothing observable has not solved anything. A common exam question asks "an algorithm must have at least ___". The answer is one output.

Input and output also fix the contract. Stating "input: a list of integers; output: the largest integer, or none if the list is empty" tells you what the algorithm is for before any step is written.

Effectiveness

Each step must be simple enough to be done exactly. Effectiveness is the criterion students most often skip. A step such as "find the shortest path" is definite in meaning but is not a basic operation. It has to be broken into steps that are. Knuth's test is whether a person with pencil and paper could carry out each step in finite time.

One Example Checked Against All Five

Here is a plain algorithm that finds the largest number in a list, followed by the check.

def find_max(numbers): if not numbers: return None largest = numbers[0] for value in numbers: if value > largest: largest = value return largest print(find_max([3, 9, 2, 7])) # 9 print(find_max([])) # None
  • Input. One list of numbers, possibly empty.
  • Output. The largest value, or None for an empty list. There is always exactly one output.
  • Definiteness. Each line does one fixed thing: compare, assign, or return.
  • Finiteness. The loop visits each of the n items once and then ends.
  • Effectiveness. Comparing two numbers and copying a value are basic operations.

An algorithm that fails any one of these is not an algorithm. Being correct and being fast are separate questions asked after these five. The criteria only decide whether the procedure counts as an algorithm at all.

Key Takeaways

TAGS
Coding Interview
CONTRIBUTOR
Arslan Ahmad
Arslan Ahmad
ex-FAANG engineering manager and author or Grokking series.

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Explore Answers
Which question Google has no answer?
What is the full form of OS?
What does a UX interview look like?
Which website to prepare for Data structures interview questions for freshers?
What is the culture of the Anthropic company?
Why are you interested in Datadog?
Related Courses
New
Grokking the AI System Design Interview course cover
Grokking the AI System Design Interview
Learn to design AI systems the way interviewers expect: classic ML products, LLM and RAG architectures, and agentic systems, all through the lens of the system design interview.
4.6
(3,192 learners)
Discounted price for Your Region

$99

Grokking the Coding Interview: Patterns for Coding Questions course cover
Grokking the Coding Interview: Patterns for Coding Questions
The 24 essential patterns behind every coding interview question. Available in Java, Python, JavaScript, C++, C#, and Go. The most comprehensive coding interview course with 543 lessons. A smarter alternative to grinding LeetCode.
4.6
Discounted price for Your Region

$197

Grokking Modern AI Fundamentals course cover
Grokking Modern AI Fundamentals
Master the fundamentals of AI today to lead the tech revolution of tomorrow.
4.1
Discounted price for Your Region

$72

Design Gurus logo
One-Stop Portal For Tech Interviews.
Copyright © 2026 Design Gurus, LLC. All rights reserved.