Algorithm

A step-by-step procedure for solving a problem or accomplishing a task.

fundamental

Algorithm

Back to Glossary

An algorithm is a finite sequence of well-defined, computer-implementable instructions, typically used to solve a class of problems or to perform a computation.

Algorithms are unambiguous specifications for performing calculations, data processing, automated reasoning, and other tasks. They form the foundation of everything we do in computer science and programming.

A good algorithm generally has the following characteristics:

  • Correctness: It should solve the problem it was designed to solve
  • Efficiency: It should use computational resources optimally
  • Finiteness: It must terminate after a finite number of steps
  • Deterministic: Given the same input, it should always produce the same output

Algorithms can be expressed in many ways, including natural language, pseudocode, flowcharts, and programming languages. The efficiency of algorithms is typically measured in terms of their time complexity (how long they take to run) and space complexity (how much memory they require).

Examples

  • Sorting algorithms arrange items in a specific order (e.g., Bubble Sort, Quick Sort)
  • Search algorithms locate items within a data structure (e.g., Binary Search)
  • Graph algorithms find paths, connectivity, or properties of graphs (e.g., Dijkstra's algorithm)
  • String matching algorithms find patterns in text (e.g., Boyer-Moore algorithm)

Further Learning

Want to see these concepts in action?