HowtoGo
Home / Algorithms / 50 Algorithms that serve a purpose
Algorithms

50 Algorithms that serve a purpose

Fifty algorithms that show up across search engines, databases, networks, and machine learning systems.

Search & Sorting

FunctionDescription
Binary Search
Finds an element in a sorted array by repeatedly halving the search interval.
Quick Sort
Divide-and-conquer sort that picks a pivot and partitions the array around it.
Merge Sort
Stable divide-and-conquer sort that splits arrays and merges them back in order.
Heap Sort
Sorts using a binary heap, in place, with no extra memory beyond the array.
Radix Sort
Non-comparative sort that orders integers digit by digit or bit by bit.
Ternary Search
Splits a sorted range into three parts to find the extremum of a unimodal function.
Insertion Sort
Builds a sorted array one element at a time; fast on small or nearly-sorted input.

Graph & Network Analysis

FunctionDescription
Dijkstra's Algorithm
Finds the shortest path from one source vertex to every other vertex in a weighted graph.
A* Search
Extends Dijkstra's with a heuristic to reach the goal faster without exploring the whole graph.
Breadth-First Search (BFS)
Explores a graph one layer at a time; finds shortest paths when edges are unweighted.
Depth-First Search (DFS)
Explores as far as possible down each branch before backtracking.
Kruskal's Algorithm
Builds a Minimum Spanning Tree by adding the cheapest edges first, skipping ones that form a cycle.
Prim's Algorithm
Builds a Minimum Spanning Tree by growing outward from a starting vertex, one edge at a time.
Bellman-Ford
Finds shortest paths from a single source and handles negative edge weights, unlike Dijkstra's.
PageRank
Scores nodes in a network by the quantity and quality of links pointing to them.
Floyd-Warshall
Computes shortest paths between every pair of vertices in a weighted graph.
Topological Sort
Orders the vertices of a directed acyclic graph so every edge points forward.

Cryptography & Security

FunctionDescription
RSA
Asymmetric encryption built on the difficulty of factoring large numbers.
AES
Symmetric block cipher for encrypting data with a shared secret key.
SHA-256
Produces a fixed 256-bit digest of any input, used for integrity checks and signatures.
Diffie-Hellman Key Exchange
Lets two parties agree on a shared secret over a channel an eavesdropper can see.
MD5 / MurmurHash
Fast, non-cryptographic hashing for checksums, lookup tables, and cache keys.

String & Text Processing

FunctionDescription
Knuth-Morris-Pratt (KMP)
Searches for a pattern in text without re-scanning characters it has already matched.
Boyer-Moore
Scans the pattern from right to left, skipping large chunks of text on a mismatch.
Rabin-Karp
Uses a rolling hash to check many candidate positions for a pattern in near-constant time each.
Levenshtein Distance
Counts the minimum single-character edits needed to turn one string into another.
Huffman Coding
Assigns shorter bit codes to more frequent symbols to compress data losslessly.

Machine Learning & Data Science

FunctionDescription
Linear Regression
Fits a straight-line relationship between a numeric target and one or more inputs.
Logistic Regression
Classifies inputs into two classes by modeling the probability of one of them.
K-Means Clustering
Groups data points into K clusters by repeatedly assigning points to the nearest center.
Decision Trees (ID3 / C4.5)
Splits data on feature thresholds to build an interpretable flowchart-like classifier.
Random Forest
Averages many decision trees trained on random subsets of data and features.
Gradient Descent
Minimizes a loss function by repeatedly stepping opposite its gradient.
K-Nearest Neighbors (KNN)
Classifies a point by majority vote among its closest labeled neighbors.
Support Vector Machines (SVM)
Finds the hyperplane that best separates two classes with the widest margin.
Principal Component Analysis (PCA)
Reduces a dataset's dimensions while keeping as much variance as possible.
Expectation-Maximization (EM)
Iteratively estimates parameters for models with unobserved hidden variables.

Optimization & Mathematics

FunctionDescription
Fast Fourier Transform (FFT)
Computes a discrete Fourier transform in O(n log n) instead of O(n²).
Euclid's Algorithm
Finds the greatest common divisor of two integers by repeated division.
Sieve of Eratosthenes
Finds every prime number up to a limit by crossing out multiples of each prime found.
Simplex Algorithm
Walks the vertices of a feasible region to solve linear programming problems.
Newton's Method
Approximates a function's root by repeatedly following its tangent line.
Monte Carlo Methods
Estimates a numeric result through repeated random sampling.

Concurrency, Caching & Networking

FunctionDescription
LRU Cache
Evicts the least recently used entry first once the cache is full.
Token Bucket / Leaky Bucket
Shapes traffic by allowing bursts up to a bucket size while enforcing a steady average rate.
Consistent Hashing
Maps keys to nodes so resizing the cluster remaps only a small fraction of keys.
Paxos / Raft
Reaches agreement on a single value across unreliable, distributed nodes.
MapReduce
Splits a computation into parallel map steps and a combining reduce step across a cluster.
TCP Congestion Control (Cubic / BBR)
Adjusts how fast a TCP connection sends data to avoid overwhelming the network.
Bloom Filter
Tests set membership in constant time and space, with no false negatives but possible false positives.