algorithms

A precise set of step-by-step instructions or rules that a computer follows to solve a problem or perform a task.

An algorithm is a finite sequence of well-defined, computer-implementable instructions, typically designed to solve a class of specific problems or to perform a computation. Algorithms are the fundamental building blocks of computer programs and are essential for automating tasks, processing data, and making decisions in computational systems. Key characteristics of a good algorithm include correctness (it produces the desired output for all valid inputs), efficiency (it uses resources like time and memory optimally), and termination (it is guaranteed to finish after a finite number of steps). Algorithms are often expressed using pseudocode, flowcharts, or a specific programming language. They can be categorized based on their design paradigms, such as divide and conquer (e.g., merge sort), dynamic programming (e.g., Fibonacci sequence calculation), greedy algorithms (e.g., Dijkstra's shortest path algorithm), and brute force. In cryptography, algorithms like hashing functions (e.g., SHA-256) and encryption algorithms (e.g., AES) are critical for security. The analysis of algorithms involves studying their performance and resource usage, often expressed using Big O notation to describe their time and space complexity.

        graph LR
  Center["algorithms"]:::main
  Rel_algorithm["algorithm"]:::related -.-> Center
  click Rel_algorithm "/terms/algorithm"
  Rel_asymptotic_notations["asymptotic-notations"]:::related -.-> Center
  click Rel_asymptotic_notations "/terms/asymptotic-notations"
  Rel_cryptocurrency_trading_algorithms["cryptocurrency-trading-algorithms"]:::related -.-> Center
  click Rel_cryptocurrency_trading_algorithms "/terms/cryptocurrency-trading-algorithms"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 Knowledge Check

1 / 5

🧒 Explain Like I'm 5

An [algorithm](/en/terms/algorithm) is like a recipe for baking a cake. It tells you exactly what ingredients to use (input), what steps to take (mix, bake), and what the result should be (output: a cake). If you follow the algorithm perfectly, you get the same result every time.

🤓 Expert Deep Dive

The formal definition of an algorithm, often tied to the Turing machine model, establishes its computability. Algorithmic complexity analysis, using Big O, Omega, and Theta notations, provides asymptotic bounds on resource usage, crucial for understanding scalability. Trade-offs often exist between time and space complexity; for instance, memoization can reduce redundant computations (time) at the cost of increased memory usage (space). Advanced algorithmic concepts include approximation algorithms for NP-hard problems, randomized algorithms offering probabilistic guarantees, and parallel algorithms designed for concurrent execution. The verification of algorithm correctness, especially for critical systems, can employ formal methods and proof assistants. Understanding algorithmic limitations, such as the Halting Problem, is fundamental to theoretical computer science.

📚 Sources