Algorithm¶
Definition¶
An algorithm is a precise, step-by-step set of instructions or a well-defined computational procedure that solves a particular problem or performs a specific task. Algorithms are fundamental in computer science and programming, providing a systematic approach to solving complex problems by breaking them down into simpler, understandable operations. They can be expressed in various forms, including pseudocode or actual programming code, and are used to perform tasks such as sorting data, searching for information, or carrying out mathematical calculations. The efficiency and correctness of an algorithm are crucial factors in determining its effectiveness in solving real-world problems and optimizing computer programs.
Context¶
Closely related to imperative programming paradigm.
Some algorithms can be designed based on algorithmic paradigms.
May be part of a data structure.
May be part of another algorithm.
May require certain data structures or ADTs in the implementation.
Characteristics¶
Well-defined: The steps of an algorithm must be clear and unambiguous.
Deterministic: The algorithm must produce the same output for a given input.
Finite: The algorithm must terminate after a finite number of steps.
Efficient: The algorithm must be efficient in terms of time and space complexity.
Input and output: The algorithm must have zero or more inputs and at least one output.
Categories¶
By algorithmic paradigm:
Divide and conquer
Dynamic programming
Greedy
Backtracking
Branch and bound
Brute force
Randomized
By functionality:
Searching
Sorting
String processing
By data structure:
Array algorithms
Linked list algorithms
Tree algorithms
Graph algorithms
By domain:
Machine learning algorithms
Cryptographic algorithms
Computational geometry algorithms
Numerical algorithms