Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

An algorithm is a sequence of well-defined steps that define an abstract solution to a problem. Use this tag when your issue is related to algorithm design.

An algorithm is a set of ordered instructions based on a formal language with the following conditions:

  • Finite. The number of instructions must be finite.
  • Executable. All instructions must be executable in some language-dependent way, in a finite amount of time.
  • Deterministic. The algorithm must be predictable.

An algorithm can be expressed in many ways:

  • As a sequence of instructions
  • As a block-scheme
  • As a code in an existing or new programming language
  • As a piece of text in a human language
  • In other similar ways.

An algorithm can solve a class of problems. For example, both "sum 1 and 3" and "sum 4 and 5" are problems in the same class: "sum two integer numbers." Furthermore, a given class of problems can generally be solved by a variety of algorithms.

One important aspect of algorithm design is performance. For large datasets, a good algorithm may outperform a poor algorithm by several orders of magnitude. Algorithm performance is often rated with Big O or Θ notation, but one should be cautious with asymptotic notation, since big constants may be involved.

A key algorithm classification is known as Algorithm Complexity.

Related Links

Additional resources on algorithms include: