Algorithms for Competitive ProgrammingThe goal of this project is to translate the wonderful resource http://e-maxx.ru/algo which provides descriptions of many algorithms and data structures especially popular in field of competitive programming. Moreover we want to improve the collected knowledge by extending the articles and adding new articles to the collection.https://cp-algorithms.com/https://github.com/cp-algorithms/cp-algorithmsenTue, 16 Jul 2024 01:32:32 -0000Tue, 16 Jul 2024 01:32:32 -00001440MkDocs RSS plugin - v1.15.0Strongly Connected Components and Condensation Graph<h1>Strongly connected components and the condensation graph</h1><h2>Definitions</h2><p>Let $G=(V,E)$ be a directed graph with vertices $V$ and edges $E \subseteq V \time...</p>https://cp-algorithms.com/graph/strongly-connected-components.html Tue, 16 Jul 2024 01:08:59 +0000Manhattan Distance<h1>Manhattan Distance</h1><h2>Definition</h2><p>For points $p$ and $q$ on a plane, we can define the distance between them as the sum of the differences between their $...</p>https://cp-algorithms.com/geometry/manhattan-distance.html Fri, 12 Jul 2024 15:23:34 +0000Navigation<ul><li>Home<ul><li><a href="index.md">Main Page</a></li><li><a href="navigation.md">Navigation</a></li><li><a href="tags.md">Tag index</a></li><li><a href="contrib.md">How to Contribute</a></li><li>[Code of conduct]...</li></ul></li></ul>https://cp-algorithms.com/navigation.html Fri, 12 Jul 2024 15:01:42 +0000Finding a Negative Cycle in the Graph<h1>Finding a negative cycle in the graph</h1><p>You are given a directed weighted graph $G$ with $N$ vertices and $M$ edges. Find any cycle of negative weight in it...</p>https://cp-algorithms.com/graph/finding-negative-cycle-in-graph.html Thu, 11 Jul 2024 14:22:19 +0000Euclidean algorithm for computing the greatest common divisor<h1>Euclidean algorithm for computing the greatest common divisor</h1><p>Given two non-negative integers $a$ and $b$, we have to find their <strong>GCD</strong> (greatest common ...</p>https://cp-algorithms.com/algebra/euclid-algorithm.html Thu, 11 Jul 2024 13:35:54 +0000String Hashing<h1>String Hashing</h1><p>Hashing algorithms are helpful in solving a lot of problems.</p><p>We want to solve the problem of comparing strings efficiently.The brute forc...</p>https://cp-algorithms.com/string/string-hashing.html Thu, 04 Jul 2024 04:53:30 +0000Balanced bracket sequences<h1>Balanced bracket sequences</h1><p>A <strong>balanced bracket sequence</strong> is a string consisting of only brackets, such that this sequence, when inserted certain numbers...</p>https://cp-algorithms.com/combinatorics/bracket_sequences.html Mon, 01 Jul 2024 17:24:59 +0000Disjoint Set Union<h1>Disjoint Set Union</h1><p>This article discusses the data structure <strong>Disjoint Set Union</strong> or <strong>DSU</strong>.Often it is also called <strong>Union Find</strong> because of its two ...</p>https://cp-algorithms.com/data_structures/disjoint_set_union.html Mon, 01 Jul 2024 08:40:02 +0000Ternary Search<h1>Ternary Search</h1><p>We are given a function $f(x)$ which is unimodal on an interval $[l, r]$. By unimodal function, we mean one of two behaviors of the functio...</p>https://cp-algorithms.com/num_methods/ternary_search.html Fri, 28 Jun 2024 10:06:33 +0000Finding Bridges in O(N+M)<h1>Finding bridges in a graph in $O(N+M)$</h1><p>We are given an undirected graph. A bridge is defined as an edge which, when removed, makes the graph disconnected ...</p>https://cp-algorithms.com/graph/bridge-searching.html Tue, 25 Jun 2024 19:33:59 +0000Maximum flow - Ford-Fulkerson and Edmonds-Karp<h1>Maximum flow - Ford-Fulkerson and Edmonds-Karp</h1><p>The Edmonds-Karp algorithm is an implementation of the Ford-Fulkerson method for computing a maximal flow i...</p>https://cp-algorithms.com/graph/edmonds_karp.html Thu, 20 Jun 2024 17:48:20 +0000Knapsack Problem<h1>Knapsack Problem</h1><p>Prerequisite knowledge: <a href="https://cp-algorithms.com/dynamic_programming/intro-to-dp.html">Introduction to Dynamic Programming</a></p><h2>Introduc...</h2>https://cp-algorithms.com/dynamic_programming/knapsack.html Thu, 20 Jun 2024 05:23:33 +00002-SAT<h1>2-SAT</h1><p>SAT (Boolean satisfiability problem) is the problem of assigning Boolean values to variables to satisfy a given Boolean formula.The Boolean formul...</p>https://cp-algorithms.com/graph/2SAT.html Wed, 19 Jun 2024 16:32:34 +0000Bit manipulation<h1>Bit manipulation</h1><h2>Binary number</h2><p>A <strong>binary number</strong> is a number expressed in the base-2 numeral system or binary numeral system, it is a method of math...</p>https://cp-algorithms.com/algebra/bit-manipulation.html Tue, 18 Jun 2024 16:10:02 +0000Fenwick Tree<h1>Fenwick Tree</h1><p>Let $f$ be some group operation (a binary associative function over a set with an identity element and inverse elements) and $A$ be an array ...</p>https://cp-algorithms.com/data_structures/fenwick.html Tue, 18 Jun 2024 01:10:33 +0000Operations on polynomials and series<h1>Operations on polynomials and series</h1><p>Problems in competitive programming, especially the ones involving enumeration some kind, are often solved by reducin...</p>https://cp-algorithms.com/algebra/polynomial.html Mon, 17 Jun 2024 22:48:19 +0000Checking a graph for acyclicity and finding a cycle in O(M)<h1>Checking a graph for acyclicity and finding a cycle in $O(M)$</h1><p>Consider a directed or undirected graph without loops and multiple edges. We have to check w...</p>https://cp-algorithms.com/graph/finding-cycle.html Mon, 10 Jun 2024 07:23:09 +0000Introduction to Dynamic Programming<h1>Introduction to Dynamic Programming</h1><p>The essence of dynamic programming is to avoid repeated calculation. Often, dynamic programming problems are naturall...</p>https://cp-algorithms.com/dynamic_programming/intro-to-dp.html Sun, 09 Jun 2024 00:24:41 +0000Finding Connected Components<h1>Search for connected components in a graph</h1><p>Given an undirected graph $G$ with $n$ nodes and $m$ edges. We are required to find in it all the connected com...</p>https://cp-algorithms.com/graph/search-for-connected-components.html Sun, 09 Jun 2024 00:14:23 +0000Depth First Search<h1>Depth First Search</h1><p>Depth First Search is one of the main graph algorithms.</p><p>Depth First Search finds the lexicographical first path in the graph from a so...</p>https://cp-algorithms.com/graph/depth-first-search.html Sat, 08 Jun 2024 21:18:51 +0000