Skip to main content

Algorithms Definition

Algorithm is a set of precise instructions designed to solve a problem or perform a task. It's like a recipe, providing step-by-step guidance to achieve a desired outcome. Algorithms are used across many fields, from computer science to everyday problem-solving.

Paradigm

  • Brute Force: look at all the possibilities and selects the best solution
  • Greedy: choose the best option at the current time, without any consideration for the future
  • Divide and Conquer - divide the problem into smaller parts and then solve those parts
  • Dynamic Programming - build up a solution using previously found sub-solutions
  • Backtracking - incrementally build candidates for a solution, but when the algorithm determines that a candidate cannot lead to a valid solution, it discards the candidate and backtracks to try another
AlgorithmTopicParadigmDefinition

Knapsack Problem

SetDynamic Programming

Optimize value by selecting items to fit into a limited-capacity knapsack

Articulation Points

GraphGraph TheoryIdentifies critical nodes whose removal would disconnect a graph

Bellman-Ford Algorithm

GraphDynamic Programming

Finds shortest paths from a single source to all other vertices in a weighted graph, even with negative edge weights. It works by repeatedly relaxing edges

Best Time To Buy Sell Stocks

Sliding Window / SetDivide and Conquer

Problem of finding the maximum profit from buying and selling stocks at the right times

Binary Floating Point

MathFloating Point Arithmetic

Representation of real numbers in binary format with a floating-point

Binary Search

SearchDivide and Conquer

Search algorithm that divides a sorted array into halves, eliminating half of the remaining elements in each step.

Bit Manipulation

MathBitwise ManipulationManipulating individual bits within binary numbers

Breadth-First Search (BFS)

Graph / TreeGraph Traversal

Traversal algorithm that systematically explores all neighbor nodes at the present depth prior to moving on to nodes at the next depth level

Bridges

GraphGraph Theory

Edges in a graph, the removal of which would increase the number of connected components

Bubble Sort

SortComparison-based Sort

A simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order

Bucket Sort

SortDistribution-based Sort

A sorting algorithm that distributes elements into a number of "buckets", and then sorts each bucket individually

Caesar Cipher

CryptographySubstitution Cipher

A substitution cipher that shifts characters in the alphabet by a fixed number of positions

Cartesian Product

SetCombinatorialSet of all possible ordered pairs from two sets

Combination Sum

Combinatorial ProblemBacktracking

Finding combinations of numbers that sum up to a given target value

Combinations

SetDivide and ConquerSelections of elements without considering the order

Complex Number

MathMathematicalA number that comprises a real part and an imaginary part

Counting Sort

SortSort

A non-comparison-based sorting algorithm that sorts elements by counting the number of occurrences of each unique element

Depth-First Search (DFS)

Graph / TreeDivide and Conquer

Traversal algorithm that explores all neighbor nodes at the present depth prior to moving on to nodes at the next depth level

Detect Graph Cycle

GraphGraphAlgorithms used to determine if a graph contains a cycle

Dijkstra Algorithm

GraphGreedy

Algorithm used to find the shortest paths from a single source node to all other nodes in a weighted graph

Discrete Fourier Transform

MathBrute Force

Transforming discrete data from the time domain to the frequency domain

Euclidean Algorithm

MathDivide and ConquerFinding the greatest common divisor of two integers

Euclidean Distance

MathMathematicalThe distance between two points in Euclidean space

Eulerian Path and Eulerian Circuit - Fleury's Algorithm

GraphGraph

Algorithms used to find paths and circuits that traverse each edge of a graph exactly once

Factorial

MathMathematicalThe product of all positive integers up to a given number

Fast Powering

MathDivide and ConquerEfficiently computing the exponentiation of a number

Fibonacci Number

MathDynamic Programming

A sequence of numbers where each number is the sum of the two preceding ones

Fisher–Yates Shuffle

SetRandomizationA method for randomly shuffling the elements of an array

Floyd-Warshall Algorithm

GraphDynamic Programming

Algorithm used to find the shortest paths between all pairs of nodes in a weighted graph

Hamiltonian Cycle

GraphBacktrackingA cycle that visits each vertex of a graph exactly once

Hamming Distance

StringMathematical

The number of positions at which corresponding symbols differ in two sequences

Heap Sort

SortSort

A sorting algorithm that utilizes the heap data structure to sort elements in ascending or descending order

Hill Cipher

CryptographyCryptographyA polygraphic substitution cipher based on linear algebra

Horner's Method

MathMathematicalAn algorithm for polynomial evaluation

Insertion Sort

SortSort

A sorting algorithm that builds a sorted list one element at a time by repeatedly inserting the next element into the already sorted part of the list

Integer Partition

MathDynamic ProgrammingRepresenting a given integer as the sum of other integers

Interpolation Search

SearchSearch

A search algorithm that extrapolates the position of the target value based on its value and the values of the array's endpoints, providing a quicker approach for uniformly distributed data

Is Power of Two

MathMathDetermining whether a given integer is a power of two

Jump Game

ArrayBacktracking / Divide and Conquer / Dynamic Programming / Greedy

Problem of determining if it's possible to reach the last index of an array starting from the first index

Jump Search (or Block Search)

SearchSearch

An algorithm that jumps ahead by fixed steps and then performs linear search within the block until the desired element is found

k-Means

Machine LearningClustering

A clustering algorithm that partitions data into k clusters based on similarities

k-NN

Machine LearningMachine Learning

k-Nearest Neighbors, a non-parametric method used for classification and regression

Knight's Tour

GraphBacktracking

Problem of finding a sequence of moves for a knight on a chessboard that visits every square exactly once

Knuth–Morris–Pratt Algorithm (KMP Algorithm)

StringString Matching

An efficient string-searching algorithm that searches for occurrences of a "word" within a larger "text"

Kruskal's Algorithm

GraphGreedy

Greedy algorithm used to find the minimum spanning tree of a connected, undirected graph

Least Common Multiple (lcm)

MathMathematical

The smallest positive integer that is divisible by two given integers

Levenshtein Distance

StringDynamic Programming

The minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into another

Linear Search

SearchBrute Force

A basic searching algorithm that sequentially examines each element in a list until a match is found

Liu Hui π Algorithm

MathMathematicalA method for approximating the value of π

Longest Common Subsequence (LCS)

SetDynamic ProgrammingThe longest sequence that is common to two or more sequences

Longest Common Substring (LCS)

StringDynamic Programming

The longest sequence of characters that appears in both given strings

Longest Increasing Subsequence (LIS)

SetDynamic ProgrammingThe longest subsequence where elements are in increasing order

Matrices

MathDivide and ConquerRectangular arrays of numbers

Maximum Subarray

ArrayBrute Force / Divide and Conquer / Dynamic Programming

Problem of finding the contiguous subarray with the largest sum within a given array

Merge Sort

SortDivide and Conquer

A divide-and-conquer sorting algorithm that recursively divides the input list into smaller sublists, sorts those sublists, and then merges them back together

N-Queens Problem

ArrayBacktracking

Problem of placing N queens on an NxN chessboard such that no two queens attack each other

NanoNeuron

Machine LearningMachine Learning

A simplified model of a neuron used for educational purposes in machine learning

Palindrome

StringString ManipulationA sequence that reads the same backward as forward

Pascal's Triangle

MathDivide and ConquerA triangular array of binomial coefficients

Permutations

SetDivide and ConquerArrangements of elements in a specific order

Polynomial Hash

CryptographyHash

A hash function that converts a string into a polynomial representation for efficient hashing

Power Set

SetBacktrackingSet of all subsets of a given set

Primality Test

MathMathematicalDetermining whether a given number is prime or composite

Prime Factors

MathMathematical

The prime numbers that multiply together to give a composite number

Prim's Algorithm

GraphGreedy

Greedy algorithm used to find the minimum spanning tree of a connected, undirected graph

Quicksort

SortDivide and Conquer

A divide-and-conquer sorting algorithm that partitions the input list into smaller sublists, recursively sorts those sublists, and then combines them

Rabin Karp Algorithm

StringString Manipulation

A string-searching algorithm that searches for patterns in a string using hashing

Radian & Degree

MathMathematicalUnits of measurement for angles

Radix Sort

SortSort

A non-comparison-based sorting algorithm that sorts elements by their digits or numbers

Rail Fence Cipher

CryptographyCryptography

A transposition cipher that encrypts and decrypts messages by shifting characters along diagonal rails

Rain Terraces

ArrayBrute Force / Dynamic Programming

Problem involving calculating the amount of water that can be trapped between blocks

Recursive Staircase

MathBrute Force / Dynamic Programming

Problem of counting the number of ways to climb a staircase with a given number of steps

Regular Expression Matching

StringDynamic Programming

Determining if a string matches a pattern specified by a regular expression

Reverse Traversal

Linked ListIteration

Traversing elements in the reverse order of their appearance in a data structure

Seam Carving

Image ProcessingDynamic Programming

An image resizing technique that removes or adds pixels in a way that preserves the most important features of the image

Selection Sort

SortSort

A sorting algorithm that divides the input list into two parts: a sorted sublist and an unsorted sublist, and repeatedly selects the smallest (or largest) element from the unsorted sublist to add to the sorted sublist

Shell Sort

SortSort

A variation of insertion sort that sorts elements at different intervals to improve performance

Shortest Common Supersequence (SCS)

SetDynamic ProgrammingThe shortest string containing both given strings as subsequences

Sieve of Eratosthenes

MathPrime NumberAn algorithm to find all prime numbers up to a specified integer

Square Root - Newton's method

MathMathAn iterative method for finding square roots

Straight Traversal

Linked ListIterationTraversing elements in the order they appear in a data structure

Strongly Connected Components - Kosaraju's Algorithm

GraphGraph

Algorithms used to find sets of vertices in a directed graph such that every vertex in the set is reachable from every other vertex

Topological Sorting

GraphGraph

Arranging the nodes of a directed graph in a linear order respecting the dependencies between nodes

Tower of Hanoi

MathDivide and Conquer / Recursion

Mathematical puzzle involving the movement of disks from one peg to another, following certain rules

Travelling Salesman Problem

GraphBrute Force

A problem that asks for the shortest possible route that visits each city exactly once and returns to the origin city

Unbound Knapsack Problem

SetDynamic Programming / Greedy

Variation of the knapsack problem where there is an unlimited supply of each item

Unique Paths

GridBacktracking / Dynamic Programming

Problem of counting the number of unique paths from the top-left corner to the bottom-right corner of a grid

Weighted Random

StatisticsRandomization

Generating random values with different probabilities assigned to each value

Z Algorithm

StringString Matchingsubstring search (pattern matching)