Skip to main content

Algorithms (Catalog)

Data structures

Catalog reference markup
  • Dictionaries

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ds-dictionaries)
  • Priority queues

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ds-priority-queues)
  • Suffix trees and arrays

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ds-suffix-trees-and-arrays)
  • Graph data structures

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ds-graph-data-structures)
  • Set data structures

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ds-set-data-structures)
  • Kd-trees

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ds-kd-trees)
  • Solving linear equations

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#np-linear-equations)
  • Bandwidth reduction

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#np-bandwidth-reduction)
  • Matrix multiplication

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#np-matrix-multiplication)
  • Determinants and permanents

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#np-determinants-and-permanents)
  • Constrained/unconstrained optimization

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#np-optimization)
  • Linear programming

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#np-linear-programming)
  • Random number generation

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#np-random-number-generation)
  • Factoring and primality testing

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#np-factoring-primality)
  • Arbitrary-precision arithmetic

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#np-arithmetic)
  • Knapsack problem

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#np-knapsack)
  • Discrete Fourier transform

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#np-fourier)
  • Sorting

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cp-sorting)
  • Searching

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cp-searching)
  • Median and selection

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cp-median-selection)
  • Generating permutations

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cp-gen-permutations)
  • Generating subsets

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cp-gen-subsets)
  • Generating partitions

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cp-gen-partitions)
  • Generating graphs

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cp-gen-graphs)
  • Calendrical calculations

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cp-calendar)
  • Job scheduling

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cp-job-scheduling)
  • Satisfiability

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cp-satisfiability)
  • Connected components

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-connected-components)
  • Topological sorting

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-topological-sorting)
  • Minimum spanning tree

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-mst)
  • Shortest path

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-shortest-path)
  • Transitive closure and reduction

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-transitive)
  • Matching

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-matching)
  • Eulerian cycle/Chinese postman

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-eulerian-cycle)
  • Edge and vertex connectivity

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-edge-vertex-connectivity)
  • Network flow

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-network-flow)
  • Drawing graphs nicely

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-drawing-graphs)
  • Drawing trees

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-drawing-trees)
  • Planarity detection and embedding

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-pt-planarity)
  • Clique

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-np-clique)
  • Independent set

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-np-independent-set)
  • Vertex cover

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-np-vertex-cover)
  • Traveling salesman problem

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-np-tsp)
  • Hamiltonian cycle

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-np-hamiltonian)
  • Graph partition

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-np-graph-partition)
  • Vertex coloring

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-np-vertex-coloring)
  • Edge coloring

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-np-edge-coloring)
  • Graph isomorphism

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-np-graph-isomorphism)
  • Steiner tree

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-np-steiner-tree)
  • Feedback edge/vertex set

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#gp-np-feedback)
  • Robust geometric primitives

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-primitives)
  • Convex hull

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-convex-hull)
  • Triangulation

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-triangulation)
  • Voronoi diagrams

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-voronoi)
  • Nearest-neighbor search

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-nearest-neighbor)
  • Range search

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-range-search)
  • Point location

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-point-location)
  • Intersection detection

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-intersection-detection)
  • Bin packing

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-bin-packing)
  • Medial-axis transform

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-medial-axis-transform)
  • Polygon partitioning

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-polygon-partitioning)
  • Simplifying polygons

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-simplifying-polygons)
  • Shape similarity

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-shape-similarity)
  • Motion planning

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-motion-planning)
  • Maintaining line arrangements

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-line-arrangements)
  • Minkowski sum

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#cg-minkowski)
  • Set cover

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ss-set-cover)
  • Set packing

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ss-set-packing)
  • String matching

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ss-string-matching)
  • Approximate string matching

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ss-string-matching-approximate)
  • Text compression

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ss-text-compression)
  • Cryptography

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ss-cryptography)
  • Fininte state machine minimization

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ss-finite-state)
  • Longest common substring/subsequence

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ss-longest-common)
  • Shortest common superstring

    [the catalog](/docs/books/algorithm-design-manual/algorithms-catalog#ss-shortest-common)

Dictionaries

Input description: A set of nn records, each identified by one or more keys.

Problem description: Build and maintain a data structure to efficiently locate, insert, and delete the record associated with any query key qq.

Priority queues

Input description: A set of records with totally ordered keys.

Problem description: Build and maintain a data structure for providing quick access to the smallest or largest key in the set.

Suffix trees and arrays

Input description: A reference string SS.

Problem description: Build a data structure for quickly finding all places where an arbitrary query string qq occurs in SS.

Graph data structures

Input description: A graph GG.

Problem description: Represent the graph GG using a flexible, efficient data structure.

Set data structures

Input description: A universe of items U={u1,,un}U=\{u_1,\ldots,u_n\} on which is defined a collection of subsets S={S1,,Sm}S=\{S_1,\ldots,S_m\}.

Problem description: Represent each subset so as to efficiently

  1. test whether uiSju_i\in S_j,
  2. compute the union or intersection of SiS_i and SjS_j, and
  3. insert or delete members of SS.

Kd-trees

Input description: A set SS of nn points (or more complicated geometric objects) in kk dimensions.

Problem description: Construct a tree that partitions space by half-planes such that each object is contained in its own box-shaped region.

Numerical problems

Solving linear equations

Input description: An m×nm\times n matrix AA and an m×1m\times 1 vector bb, together representing mm linear equations on nn variables.

Problem description: What is the vector xx such that Ax=bA\cdot x=b?

Bandwidth reduction

Input description: A graph G=(V,E)G=(V,E), representing an n×nn\times n matrix MM of zero and non-zero elements.

Problem description: Which permutation pp of the vertices minimizes the length of the longest edge--i.e., minimizes max(i,j)Ep(i)p(j)\max_{(i,j)\in E}|p(i)-p(j)|?

Matrix multiplication

Input description: An x×yx\times y matrix AA and a y×zy\times z matrix BB.

Problem description: Compute the x×zx\times z matrix A×BA\times B.

Determinants and permanents

Input description: An n×nn\times n matrix MM.

Problem description: What is the determinant M|M| or permanent perm(M)\operatorname{perm}(M) of the matrix MM?

Constrained/unconstrained optimization

Input description: A function f(x1,,xn)f(x_1,\ldots,x_n).

Problem description: Which point p=(p1,,pn)p=(p_1,\ldots,p_n) maximizes (or minimizes) the function ff?

Linear programming

Input description: A set SS of nn linear inequalities on mm variables

Si=j=1mcijxjbi,1inS_i=\sum_{j=1}^m c_{ij}\cdot x_j\geq b_i,\quad 1\leq i\leq n

and a linear optimization function f(X)=j=1mcjxjf(X)=\sum_{j=1}^m c_j\cdot x_j.

Problem description: Which variable assignment XX' maximizes the objective function ff while satisfying all inequalities SS?

Random number generation

Input description: Nothing, or perhaps a seed.

Problem description: Generate a sequence of random integers.

Factoring and primality testing

Input description: An integer nn.

Problem description: Is nn a prime number? If not, what are its factors?

Arbitrary-precision arithmetic

Input description: Two very large integers, xx and yy.

Problem description: What is x+yx+y, xyx-y, x×yx\times y, and x/yx/y?

Knapsack problem

Input description: A set of items S={1,,n}S=\{1,\ldots,n\}, where item ii has size sis_i and value viv_i. A knapsack capacity CC.

Problem description: Find the subset SS' of SS that maximizes the value of iSvi\sum_{i\in S'}v_i given iSsiC\sum_{i\in S'}s_i\leq C; that is, all the items fit in a knapsack of size CC.

Discrete Fourier transform

Input description: A sequence of nn real or complex values hih_i, 0in10\leq i\leq n-1, sampled at uniform intervals from a function hh.

Problem description: The discrete Fourier transform Hm=k=0n1hke2πikm/nH_m=\sum_{k=0}^{n-1}h_ke^{-2\pi ikm/n} for 0mn10\leq m\leq n-1.

Combinatorial problems

Sorting

Input description: A set of nn items.

Problem description: Arrange the items in increasing order.

Searching

Input description: A set of nn keys SS, and a query key qq.

Problem description: Where is qq in SS?

Median and selection

Input description: A set of nn numbers or keys, and an integer kk.

Problem description: Find the key greater than or equal to exactly kk of the nn keys.

Generating permutations

Input description: An integer nn.

Problem description: Generate

  1. all, or
  2. a random, or
  3. the next permutation of length nn.

Generating subsets

Input description: An integer nn.

Problem description: Generate

  1. all, or
  2. a random, or
  3. the next subset of the integers {1,,n}\{1,\ldots,n\}.

Generating partitions

Input description: An integer nn.

Problem description: Generate

  1. all, or
  2. a random, or
  3. the next integer or set partitions of length nn.

Generating graphs

Input description: Parameters describing the desired graph, including the number of vertices nn, and the number of edges mm or edge probability pp.

Problem description: Generate

  1. all, or
  2. a random, or
  3. the next graph satisfying the parameters.

Calendrical calculations

Input description: A particular calendar date dd: month, day, and year.

Problem description: Which day of the week did dd fall on according to the given calendar system?

Job scheduling

Input description: A directed acyclic graph G=(V,E)G=(V,E), with vertices representing jobs, and edge (u,v)(u,v) implies task uu must be done before task vv.

Problem description: Which schedule of tasks completes the job using the minimum amount of time or processors?

Satisfiability

Input description: A set of clauses in conjunctive normal form.

Problem description: Is there a truth assignment to the Boolean variables such that every clause is simultaneously satisfied?

Graph Problems - Polynomial Time

Connected components

Input description: A directed or undirected graph GG.

Problem description: Identify the different pieces or components of GG, where vertices xx and yy are in different components when no path exists from xx to yy in GG.

Topological sorting

Input description: A directed acyclic graph G=(V,E)G=(V,E), also known as a partial order or poset.

Problem description: Find a linear ordering of the vertices of VV such that for each edge (i,j)E(i,j)\in E, vertex ii is to the left of vertex jj.

Minimum spanning tree

Input description: A graph G=(V,E)G=(V,E) with weighted edges.

Problem description: Find a subset of edges EEE'\subset E that define a tree of minimum weight on VV.

Shortest path

Input description: An edge-weighted graph GG, with vertices ss and tt.

Problem description: Find the shortest path from ss to tt in GG.

Transitive closure and reduction

Input description: A directed graph G=(V,E)G=(V,E).

Problem description: For transitive closure, construct a graph GG'  with edge (i,j)E(i, j)\in E' iff there is a directed path from ii to jj in GG. For transitive reduction, construct a graph GG' with the smallest number of edges such that a directed path from ii to jj exists in GG' iff there is a directed path from ii to jj in GG.

Matching

Input description: A (weighted) graph G=(V,E)G = (V,E).

Problem description: Find the largest set of edges EE' from EE such that every vertex in VV is incident to at most one edge of EE'.

Eulerian cycle/Chinese postman

Input description: A graph G=(V,E)G=(V,E).

Problem description: Find the shortest tour visiting every edge of GG.

Edge and vertex connectivity

Input description: A graph GG. Optionally, a pair of vertices ss and tt.

Problem description: What is the smallest subset of vertices (or edges) whose deletion will disconnect GG, or that will separate ss from tt?

Network flow

Input description: A directed graph GG, where each edge e=(i,j)e=(i,j) has a capacity cec_e. A source node ss and sink node tt.

Problem description: What is the maximum flow you can route from ss to tt while respecting the capacity constraint of each edge?

Drawing graphs nicely

Input description: A graph GG.

Problem description: Draw a graph GG to accurately reflect its structure.

Drawing trees

Input description: A tree TT, which is a graph without any cycles.

Problem description: Create a nice drawing of the tree TT.

Planarity detection and embedding

Input description: A graph GG.

Problem description: Can GG be drawn in the plane such that no two edges cross? If so, produce such a drawing.

Graph Problems - NP-Hard

Clique

Input description: A graph G=(V,E)G=(V,E).

Problem description: What is the largest subset SS of vertices such that all pairs are connected, that is, for all x,ySx,y\in S, (x,y)E(x,y)\in E?

Independent set

Input description: A graph G=(V,E)G=(V,E).

Problem description: What is the largest subset SS of vertices VV such that there is no edge (x,y)E(x,y)\in E where xSx\in S and ySy\in S?

Vertex cover

Input description: A graph G=(V,E)G=(V,E).

Problem description: What is the smallest subset CVC\subseteq V such that every edge (x,y)E(x,y)\in E contains at least one vertex of CC?

Traveling salesman problem

Input description: A weighted graph GG.

Problem description: Find the cycle of minimum cost, visiting each vertex of GG exactly once.

Hamiltonian cycle

Input description: A graph G=(V,E)G=(V,E).

Problem description: Find a tour of the vertices using only edges from GG, such that each vertex is visited exactly once.

Graph partition

Input description: A (weighted) graph G=(V,E)G=(V,E) and integers kk and mm.

Problem description: Partition the vertices into mm roughly equal-sized subsets such that the total cost of edges spanning the subsets is at most kk.

Vertex coloring

Input description: A graph G=(V,E)G=(V,E).

Problem description: Color the vertices of VV using the minimum number of colors such that for all (i,j)E(i,j)\in E, vertices ii and jj have different colors.

Edge coloring

Input description: A graph G=(V,E)G=(V,E).

Problem description: What is the smallest set of colors needed to color the edges of GG such that no two edges of the same color share a common vertex?

Graph isomorphism

Input description: Two graphs, GG and HH.

Problem description: Find a mapping ff from the vertices of GG to the vertices of HH such that GG and HH are identical, that is, (x,y)(x,y) is an edge of GG iff (f(x),f(y))(f(x),f(y)) is an edge of HH.

Steiner tree

Input description: A graph G=(V,E)G=(V,E) and specified subset of vertices TVT\subseteq V. Or set of geometric points TT.

Problem description:

Feedback edge/vertex set

Input description: A (directed) graph G=(V,E)G=(V,E).

Problem description: What is the smallest set of edges EE' or vertices VV' whose deletion leaves an acyclic graph?

Computational geometry

Robust geometric primitives

Input description: A point pp and line segment \ell, or two segments 1\ell_1, 2\ell_2.

Problem description: Does pp lie on, over, or under \ell? Does 1\ell_1 intersect 2\ell_2?

Convex hull

Input description: A set SS of nn points in dd-dimensional space.

Problem description: Find the smallest convex polygon (or polyhedron) containing all the points of SS.

Triangulation

Input description: A set of points, a polygon, or a polyhedron.

Problem description: Partition the interior of the point set or polyhedron into triangles.

Voronoi diagrams

Input description: A set SS of points p1,,pnp_1,\ldots,p_n.

Problem description: Decompose space into regions such that all points in the region around pip_i are closer to pip_i than to any other point in SS.

Nearest-neighbor search

Input description: A set SS of nn points in dd dimensions, and query point qq.

Problem description: Which point in SS is closest to qq?

Input description: A set SS of nn points in dd dimensions, and a query region QQ.

Problem description: Which points in SS lie within QQ?

Point location

Input description: A decomposition of the plane into polygonal regions, and a query point qq.

Problem description: Which region contains the query point qq?

Intersection detection

Input description: A set SS of lines and line segments 1,,n\ell_1,\ldots,\ell_n, or a pair of polygons or polyhedra P1P_1 and P2P_2.

Problem description: Which pairs of line segments intersect each other? What is the intersection of P1P_1 and P2P_2.

Bin packing

Input description: A set of nn items with sizes d1,,dnd_1,\ldots,d_n. A set of mm bins with capacities c1,,cmc_1,\ldots,c_m.

Problem description: Store all the items using the fewest number of bins.

Medial-axis transform

Input description: A polygon or polyhedron PP.

Problem description: Find the skeleton of PP, the set of points that have more than one closest point on the boundary of PP.

Polygon partitioning

Input description: A polygon or polyhedron PP.

Problem description: Partition PP into a small number of simple (typically convex) pieces.

Simplifying polygons

Input description: A polygon or polyhedron pp, with nn vertices.

Problem description: Find a polygon or polyhedron pp' containing only nn' vertices, such that the shape of pp' is as close as possible to pp.

Shape similarity

Input description: Two polygonal shapes, P1P_1 and P2P_2.

Problem description: How similar are P1P_1 and P2P_2.

Motion planning

Input description: A polygonal-shaped robot starting at position ss in a room containing polygonal obstacles, and a goal position tt.

Problem description: Find the shortest route taking ss to tt without intersecting any obstacles.

Maintaining line arrangements

Input description: A set of lines 1,,n\ell_1,\ldots,\ell_n.

Problem description: What is the decomposition of the plane defined by 1,,n\ell_1,\ldots,\ell_n.

Minkowski sum

Input description: Point sets or polygons AA and BB, containing $$ and mm vertices respectively.

Problem description: What is the convolution of AA and BB, that is, the Minkowski sum A+B={x+yxA,yB}A+B=\{x+y\mid x\in A, y\in B\}?

Set and string problems

Set cover

Input description: A collection of subsets S={S1,,Sm}S=\{S_1,\ldots,S_m\} of the universal set U={1,,n}U=\{1,\ldots,n\}.

Problem description: What is the smallest subset TT of SS whose union equals the universal set, that is,

i=1TTi=U?\cup_{i=1}^{|T|}T_i=U?

Set packing

Input description: A collection of subsets S={S1,,Sm}S=\{S_1,\ldots,S_m\} of the universal set U={1,,n}U=\{1,\ldots,n\}.

Problem description: Select a small collection of mutually disjoint subsets from SS whose union is the universal set.

String matching

Input description: A text string tt of length nn. A pattern pp of length mm.

Problem description: Find an/all instances of pattern pp in the text.

Approximate string matching

Input description: A text string tt and a pattern string pp.

Problem description: What is the minimum-cost way to transform tt to pp using insertions, deletions, and substitutions?

Text compression

Input description: A text string SS.

Problem description: Create a shorter text string SS' such that SS can be correctly reconstructed from SS'.

Cryptography

Input description: A plaintext message TT or encrypted text EE, and key kk.

Problem description: Encode TT using kk giving EE, or decode EE giving TT.

Fininte state machine minimization

Input description: A deterministic finite automaton MM.

Problem description: Create the smallest deterministic finite automaton MM' such that MM' behaves identically to MM.

Longest common substring/subsequence

Input description: A set SS of strings S1,,SnS_1,\ldots,S_n.

Problem description: What is the longest string SS' such that all the characters of SS' appear as a substring or subsequence of each SiS_i, 1in1\leq i\leq n?

Shortest common superstring

Input description: A set of strings S={S1,,Sm}S=\{S_1,\ldots,S_m\}.

Problem description: Find the shortest string SS' that contains each string SiS_i as a substring of SS'.