# Classification of Algorithms

18 August 2023

In computer science or any other domain, you might have encountered the term “algorithm,” whether online or during conversations about technology. It’s a term that people use often, but you’ve likely considered its exact meaning. This question has likely crossed your mind multiple times: What are algorithms? How do they work? What are the steps in their working procedure? To begin, let’s start with an Introduction to algorithms and Classification.

# What is Algorithm?

In simple terms, we refer to “any series of well-defined steps that outlines a procedure for solving a specific type of problem” as an algorithm. It means if you have a problem, then to solve this particular problem you have to find the solution. So the steps you take to discover the solution are termed algo or algorithm.

Algorithms find use in various fields beyond computer science for problem-solving and process streamlining. They appear in everyday activities such as item sorting, information retrieval, decision-making, as well as more intricate tasks like data analysis, cryptography, and artificial intelligence.

You may also like : https://apalgorithm.com/what-is-algorithm-introduction-to-algorithm/

## Classification of Algorithms

There are various ways to classify algorithms. Let’s look at some of the major classifications. We can classify as follows. Which will be very convenient.

• By Implementation
• Optimization Problems
• By Field of Study
• By Complexity
• Continuous Algorithm

## By Implementation

• Recursion Algorithm – Recursive algorithms get the result for the current input by executing simple operations on the reciprocal value for the simpler or smaller input. They do this by using smaller input values to call themselves. When it comes to develop a recursive algorithm, we need to break the provided problem statement into two parts. The base case is the primary, and the recursive step is the second.
• Serial, parallel or distributed Algorithm – Serial algorithms execute step by step sequentially, while parallel algorithms perform steps concurrently to speed up computation on multi-core systems. Distributed algorithms operate on interconnected systems to collaboratively solve problems, suitable for tasks spread across a network of computers.
• Deterministic or non-deterministic Algorithm – Deterministic algorithms produce the same output for a given input every time they run, ensuring predictability and repeatability. Non-deterministic algorithms introduce randomness or uncertainty during execution, yielding varying outcomes for the same input, often used for optimization, search, or approximation problems.
• Exact or approximate – Exact algorithms guarantee precise solutions to problems, ensuring accuracy but potentially demanding extensive computational resources. Approximate algorithms provide solutions close to the optimal, sacrificing perfection for faster computation, useful when exact solutions are impractical due to complexity, time constraints, or resource limitations.
• Quantum algorithm – Quantum algorithms leverage quantum mechanical properties to process information in quantum bits (qubits), enabling exponential speedup for specific problems like factoring large numbers and database searching. Quantum computers exploit superposition and entanglement, potentially revolutionizing fields reliant on complex calculations and optimization.

• Brute-force or exhaustive search – Brute-force or exhaustive search algorithms solve problems by systematically examining all possible solutions. They guarantee finding the best solution but can be slow for complex problems due to their exhaustive nature. They are effective for small instances or when other more efficient methods are unavailable.
• Divide and conquer – Divide and conquer is an algorithmic technique that breaks down a problem into smaller subproblems, solves them independently, and then combines their solutions to solve the original problem. It’s used in sorting (e.g., Merge Sort) and searching (e.g., Binary Search), improving efficiency by reducing problem complexity and increasing parallelism.
• Search and enumeration – Search and enumeration algorithms systematically explore solution spaces to find desired outcomes. Examples include depth-first search and breadth-first search. They’re essential for combinatorial problems, puzzle-solving, and decision-making tasks, ensuring comprehensive coverage of possibilities, albeit potentially suffering from high time complexity on larger search spaces.
• Randomized algorithm – Randomized algorithms introduce randomness in their execution to achieve fast approximations for problems that might be time-consuming to solve exactly. Examples include randomized quicksort and Monte Carlo simulations. They provide probabilistic results that are often sufficient and are useful for optimization, cryptography, and data analysis tasks.
• Reduction of complexity – Complexity reduction involves transforming a problem into a simpler form or mapping it to a known problem class, preserving solution equivalence. For instance, NP-completeness reductions demonstrate that if one NP-complete problem can be solved efficiently, all NP problems can. It aids in understanding problem relationships and identifying efficient solutions for challenging tasks.
• Back tracking – Backtracking is a technique where algorithms explore various possibilities and undo choices that lead to dead ends, allowing efficient search for solutions in complex problem spaces by pruning unproductive paths.

## Optimization problems

• Linear programming – Linear programming optimizes a linear objective function within defined constraints. Widely used in optimization, it finds the best feasible solution for resource allocation problems. Simplex method and interior point methods are common approaches, applied in fields like economics, engineering, and operations research.
• Dynamic programming – Dynamic programming solves complex problems by breaking them into overlapping subproblems, solving each subproblem only once and storing its solution for future reference. Widely used in optimization, it’s efficient for problems with optimal substructure and overlapping subproblems, like shortest path and sequence alignment tasks.
• The greedy method – The greedy method selects the best available option at each step to build a solution incrementally, aiming for local optimization. It’s simple and fast but may not guarantee a globally optimal result. Greedy algorithms are used in tasks like coin change, scheduling, and minimal spanning trees.
• The heuristic method – The heuristic method employs practical strategies to find approximate solutions for complex problems when an optimal solution is hard to compute. It involves rule-of-thumb, intuitive, or experience-based techniques that prioritize speed over accuracy, useful for optimization, search, and decision-making tasks in real-world scenarios.

## By Field of study

Algorithms can be classified based on the field of study they are primarily used in. Here are some common categories:

1. Computer Science Algorithms: Algorithms related to data structures, sorting, searching, graph theory, and computational complexity.
2. Numerical Algorithms: Algorithms for numerical analysis, solving equations, optimization, and interpolation, commonly used in scientific computing and engineering.
3. Cryptography Algorithms: Algorithms for secure communication, encryption, decryption, and digital signatures, crucial for information security.
4. Machine Learning Algorithms: Algorithms for pattern recognition, regression, clustering, and neural networks, used in artificial intelligence and data analysis.
5. Natural Language Processing (NLP) Algorithms: Algorithms for text analysis, sentiment analysis, language generation, and machine translation, applied in language-related tasks.
6. Optimization Algorithms: Algorithms for finding optimal solutions in various domains like linear programming, integer programming, and evolutionary algorithms.
7. Geometric Algorithms: Algorithms for solving geometric problems like convex hulls, nearest neighbor search, and geometric transformations, applied in computer graphics and robotics.
8. Bioinformatics Algorithms: Algorithms for DNA sequence alignment, protein structure prediction, and molecular modeling, crucial in biology and genetics research.
9. Database Algorithms: Algorithms for indexing, query optimization, and transaction management in databases, essential for efficient data management.
10. Game Theory Algorithms: Algorithms for strategic decision-making in competitive scenarios, used in economics, social sciences, and game development.
11. Quantum Computing Algorithms: Algorithms designed to run on quantum computers, exploiting quantum properties for solving problems like factoring and optimization.
12. Robotics Algorithms: Algorithms for robot control, motion planning, and sensor fusion, fundamental in robotics and autonomous systems.
13. Financial Algorithms: Algorithms for portfolio optimization, risk assessment, and stock market analysis, utilized in finance and investment strategies.
14. Compiler Algorithms: Algorithms for code analysis, optimization, and translation, integral to programming language compilers.

## By Complexity

Algorithms can be classified based on their computational complexity, which refers to the amount of resources (time and/or space) required to execute an algorithm as a function of the input size. Here are common complexity classes:

1. Constant Time (O(1)): Complexity remains constant regardless of input size, such as accessing an element in an array.
2. Logarithmic Time (O(log n)): Complexity grows logarithmically with input size, common in binary search or divide and conquer algorithms.
3. Linear Time (O(n)): Complexity scales linearly with input size, like iterating through an array or list.
4. Linearithmic Time (O(n log n)): Complexity increases linearithmically, often seen in efficient sorting algorithms like merge sort and heap sort.
5. Quadratic Time (O(n^2)): Complexity grows with the square of input size, typical of algorithms with nested loops.
6. Cubic Time (O(n^3)): Complexity increases with the cube of input size, seen in algorithms with three nested loops.
7. Exponential Time (O(2^n) or O(3^n)): Complexity grows exponentially, becoming impractical for larger input sizes, often associated with brute-force algorithms.
8. Factorial Time (O(n!)): Complexity grows factorially, used in algorithms that consider all permutations or combinations.
9. Polynomial Time (P): Algorithms with complexity bounded by a polynomial function of input size. These problems are generally considered tractable.
10. Non-deterministic Polynomial Time (NP): Algorithms that can be verified in polynomial time, but finding a solution is non-deterministic and may be difficult.
11. Polynomial-Time Solvable (P): Problems that can be solved in polynomial time using deterministic algorithms.
12. NP-Complete: A class of problems that are at least as hard as the hardest problems in NP. No polynomial-time solution is known, but solutions can be verified in polynomial time.
13. NP-Hard: A class of problems that are at least as hard as NP-complete problems. Solutions may or may not be verifiable in polynomial time.

## Continuous algorithms

Continuous algorithms operate on continuous data or domains, where input or output can take any real value within a range. They are common in fields like mathematics, physics, engineering, and simulations. Continuous algorithm categories include:

1. Numerical Analysis Algorithms: Solving continuous mathematical problems, such as root-finding, integration, and differential equations.
2. Optimization Algorithms: Finding the best solution within a continuous search space, like gradient descent for optimization problems.
3. Interpolation and Approximation Algorithms: Estimating continuous functions using data points, for example, polynomial interpolation.
4. Integration Algorithms: Approximating the integral of a function numerically, using methods like the trapezoidal rule or Simpson’s rule.
5. Differential Equations Algorithms: Solving ordinary or partial differential equations, critical in simulating dynamic systems.
6. Curve Fitting Algorithms: Finding the best-fit curve to a set of data points, often with regression techniques.
7. Monte Carlo Simulation: Using random sampling to approximate solutions for continuous problems, from estimating integrals to simulating physical systems.
8. Finite Element Analysis (FEA): Simulating physical phenomena by dividing continuous domains into smaller elements and solving equations for each element.
9. Signal Processing Algorithms: Analyzing and manipulating continuous signals, such as filtering, noise reduction, and Fourier analysis.
10. Numerical Linear Algebra: Algorithms for solving linear equations and eigenvalue problems with continuous matrices.