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 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 .
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 .
Problem description: Build a data structure for quickly finding all places where an arbitrary query string occurs in .
Graph data structures
Input description: A graph .
Problem description: Represent the graph using a flexible, efficient data structure.
Set data structures
Input description: A universe of items on which is defined a collection of subsets .
Problem description: Represent each subset so as to efficiently
- test whether ,
- compute the union or intersection of and , and
- insert or delete members of .
Kd-trees
Input description: A set of points (or more complicated geometric objects) in 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 matrix and an vector , together representing linear equations on variables.
Problem description: What is the vector such that ?
Bandwidth reduction
Input description: A graph , representing an matrix of zero and non-zero elements.
Problem description: Which permutation of the vertices minimizes the length of the longest edge--i.e., minimizes ?
Matrix multiplication
Input description: An matrix and a matrix .
Problem description: Compute the matrix .
Determinants and permanents
Input description: An matrix .
Problem description: What is the determinant or permanent of the matrix ?
Constrained/unconstrained optimization
Input description: A function .
Problem description: Which point maximizes (or minimizes) the function ?
Linear programming
Input description: A set of linear inequalities on variables
and a linear optimization function .
Problem description: Which variable assignment maximizes the objective function while satisfying all inequalities ?
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 .
Problem description: Is a prime number? If not, what are its factors?
Arbitrary-precision arithmetic
Input description: Two very large integers, and .
Problem description: What is , , , and ?
Knapsack problem
Input description: A set of items , where item has size and value . A knapsack capacity .
Problem description: Find the subset of that maximizes the value of given ; that is, all the items fit in a knapsack of size .
Discrete Fourier transform
Input description: A sequence of real or complex values , , sampled at uniform intervals from a function .
Problem description: The discrete Fourier transform for .
Combinatorial problems
Sorting
Input description: A set of items.
Problem description: Arrange the items in increasing order.
Searching
Input description: A set of keys , and a query key .
Problem description: Where is in ?
Median and selection
Input description: A set of numbers or keys, and an integer .
Problem description: Find the key greater than or equal to exactly of the keys.
Generating permutations
Input description: An integer .
Problem description: Generate
- all, or
- a random, or
- the next permutation of length .
Generating subsets
Input description: An integer .
Problem description: Generate
- all, or
- a random, or
- the next subset of the integers .
Generating partitions
Input description: An integer .
Problem description: Generate
- all, or
- a random, or
- the next integer or set partitions of length .
Generating graphs
Input description: Parameters describing the desired graph, including the number of vertices , and the number of edges or edge probability .
Problem description: Generate
- all, or
- a random, or
- the next graph satisfying the parameters.
Calendrical calculations
Input description: A particular calendar date : month, day, and year.
Problem description: Which day of the week did fall on according to the given calendar system?
Job scheduling
Input description: A directed acyclic graph , with vertices representing jobs, and edge implies task must be done before task .
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 .
Problem description: Identify the different pieces or components of , where vertices and are in different components when no path exists from to in .
Topological sorting
Input description: A directed acyclic graph , also known as a partial order or poset.
Problem description: Find a linear ordering of the vertices of such that for each edge , vertex is to the left of vertex .
Minimum spanning tree
Input description: A graph with weighted edges.
Problem description: Find a subset of edges that define a tree of minimum weight on .
Shortest path
Input description: An edge-weighted graph , with vertices and .
Problem description: Find the shortest path from to in .
Transitive closure and reduction
Input description: A directed graph .
Problem description: For transitive closure, construct a graph with edge iff there is a directed path from to in . For transitive reduction, construct a graph with the smallest number of edges such that a directed path from to exists in iff there is a directed path from to in .
Matching
Input description: A (weighted) graph .
Problem description: Find the largest set of edges from such that every vertex in is incident to at most one edge of .
Eulerian cycle/Chinese postman
Input description: A graph .
Problem description: Find the shortest tour visiting every edge of .
Edge and vertex connectivity
Input description: A graph . Optionally, a pair of vertices and .
Problem description: What is the smallest subset of vertices (or edges) whose deletion will disconnect , or that will separate from ?
Network flow
Input description: A directed graph , where each edge has a capacity . A source node and sink node .
Problem description: What is the maximum flow you can route from to while respecting the capacity constraint of each edge?
Drawing graphs nicely
Input description: A graph .
Problem description: Draw a graph to accurately reflect its structure.
Drawing trees
Input description: A tree , which is a graph without any cycles.
Problem description: Create a nice drawing of the tree .
Planarity detection and embedding
Input description: A graph .
Problem description: Can 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 .
Problem description: What is the largest subset of vertices such that all pairs are connected, that is, for all , ?
Independent set
Input description: A graph .
Problem description: What is the largest subset of vertices such that there is no edge where and ?
Vertex cover
Input description: A graph .
Problem description: What is the smallest subset such that every edge contains at least one vertex of ?
Traveling salesman problem
Input description: A weighted graph .
Problem description: Find the cycle of minimum cost, visiting each vertex of exactly once.
Hamiltonian cycle
Input description: A graph .
Problem description: Find a tour of the vertices using only edges from , such that each vertex is visited exactly once.
Graph partition
Input description: A (weighted) graph and integers and .
Problem description: Partition the vertices into roughly equal-sized subsets such that the total cost of edges spanning the subsets is at most .
Vertex coloring
Input description: A graph .
Problem description: Color the vertices of using the minimum number of colors such that for all , vertices and have different colors.
Edge coloring
Input description: A graph .
Problem description: What is the smallest set of colors needed to color the edges of such that no two edges of the same color share a common vertex?
Graph isomorphism
Input description: Two graphs, and .
Problem description: Find a mapping from the vertices of to the vertices of such that and are identical, that is, is an edge of iff is an edge of .
Steiner tree
Input description: A graph and specified subset of vertices . Or set of geometric points .
Problem description:
Feedback edge/vertex set
Input description: A (directed) graph .
Problem description: What is the smallest set of edges or vertices whose deletion leaves an acyclic graph?
Computational geometry
Robust geometric primitives
Input description: A point and line segment , or two segments , .
Problem description: Does lie on, over, or under ? Does intersect ?
Convex hull
Input description: A set of points in -dimensional space.
Problem description: Find the smallest convex polygon (or polyhedron) containing all the points of .
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 of points .
Problem description: Decompose space into regions such that all points in the region around are closer to than to any other point in .
Nearest-neighbor search
Input description: A set of points in dimensions, and query point .
Problem description: Which point in is closest to ?
Range search
Input description: A set of points in dimensions, and a query region .
Problem description: Which points in lie within ?
Point location
Input description: A decomposition of the plane into polygonal regions, and a query point .
Problem description: Which region contains the query point ?
Intersection detection
Input description: A set of lines and line segments , or a pair of polygons or polyhedra and .
Problem description: Which pairs of line segments intersect each other? What is the intersection of and .
Bin packing
Input description: A set of items with sizes . A set of bins with capacities .
Problem description: Store all the items using the fewest number of bins.
Medial-axis transform
Input description: A polygon or polyhedron .
Problem description: Find the skeleton of , the set of points that have more than one closest point on the boundary of .
Polygon partitioning
Input description: A polygon or polyhedron .
Problem description: Partition into a small number of simple (typically convex) pieces.
Simplifying polygons
Input description: A polygon or polyhedron , with vertices.
Problem description: Find a polygon or polyhedron containing only vertices, such that the shape of is as close as possible to .
Shape similarity
Input description: Two polygonal shapes, and .
Problem description: How similar are and .
Motion planning
Input description: A polygonal-shaped robot starting at position in a room containing polygonal obstacles, and a goal position .
Problem description: Find the shortest route taking to without intersecting any obstacles.
Maintaining line arrangements
Input description: A set of lines .
Problem description: What is the decomposition of the plane defined by .
Minkowski sum
Input description: Point sets or polygons and , containing $$ and vertices respectively.
Problem description: What is the convolution of and , that is, the Minkowski sum ?
Set and string problems
Set cover
Input description: A collection of subsets of the universal set .
Problem description: What is the smallest subset of whose union equals the universal set, that is,
Set packing
Input description: A collection of subsets of the universal set .
Problem description: Select a small collection of mutually disjoint subsets from whose union is the universal set.
String matching
Input description: A text string of length . A pattern of length .
Problem description: Find an/all instances of pattern in the text.
Approximate string matching
Input description: A text string and a pattern string .
Problem description: What is the minimum-cost way to transform to using insertions, deletions, and substitutions?
Text compression
Input description: A text string .
Problem description: Create a shorter text string such that can be correctly reconstructed from .
Cryptography
Input description: A plaintext message or encrypted text , and key .
Problem description: Encode using giving , or decode giving .
Fininte state machine minimization
Input description: A deterministic finite automaton .
Problem description: Create the smallest deterministic finite automaton such that behaves identically to .
Longest common substring/subsequence
Input description: A set of strings .
Problem description: What is the longest string such that all the characters of appear as a substring or subsequence of each , ?
Shortest common superstring
Input description: A set of strings .
Problem description: Find the shortest string that contains each string as a substring of .