You are on page 1of 2

Algorithm Library

Author(s): Anshuman Singh,Aja y Somani

If you need the implementation of any of the algorithms mentioned here, just write to me

Graph Algorithms
Basic algorithms like BFS, DFS, topological Sorting, Strongly Connected Components etc.
Bellman Ford and Dijkstra's algorithm ( single source shortest paths )
Prim's and Kruskal Algorithm (generation of minimum spanning tree), Kruskals implemented using the Disjoint S
Dynamic Programming in tree to reduce many O(n2) algorithms to O(n).
Diameter of a tree using Breadth First Search.
Dominance tree from a flow graph in O(E*alpha(V,E)) where alpha is the functional inverse of ackerman's function

Flow Network Algorithms

Ford Fulkerson Algorithm using BFS to find Augmenting Paths
Dinics Algorithm ( A push relable algorithm implemented along with heuristics )
Hopcroft Karp (Maximum Bipartite matching) in O(E*sqrt(v))
Hungarian Algorithm (Maximum weighted Bipartite matching) in O(n^3)
Min-cost maximum flow uses Dijkstra algorithm to find augmenting path in each iteration.

Data Structures

Dancing Links(dlx) by Knuth to solve Exact Cover problem very efficiently. Exact cover is an NP-Complete problem
popular problems like Sudoku Problem, Tiling Problem, N-Queens problem are an example of Exact Cover problem an
efficiently solved using the data structure
Disjoint Set data structure using weighted Union and path compression heuristics
Integer and string hashing methods (through trie etc.)
2-d and 1-d segment tree. ( for Computational geometry and other query processing systems).
Fenwick Tree.
Range minimum/maximum query [O(n,1) preprocessing and query processing complexity ].

String Algorithms

Rabin Karp Algorithm.

Knuth Morris Pratt Algorithm.
Aho Corisack Algorithm
Suffix Array [ O(n) implementation ].
Patricia Trie and Suffix Trie ( O(n2) space and time complexity )

Number Theory

Prime detection Algorithms such as Fermat test , Miller's test , Solovey-Strassen test
Solution to modular equations and Extended Euclidean Algorithm.
Pollard Rho's Algorithm and Continued Fraction approach for factorizing large numbers.
Fast Fourier Transform ( Used in BigInteger class multiplication operation ).

Computational Geometry

Convex Hull Algorithms like Graham Scan, Monoton Chan.

Line sweep Algorithm to optimize solution to different problems [ e.g. : area of union of rectangles in O(nlog(n)) )..
Manhattan minimum spanning tree.
Minimum enclosing circle of n points in O(n).
Different orthogonal range query processing algorithms.
Closest distance between two segments in both 2-d and 3-d geometry.

Linear Algebra

Determinant of matrix in O(n4) without using any floating point operations.

Calculation of rank and inverse of a matrix.
Solution to a system of linear equations.
LUP decomposition of a matrix.
nth term of any sequence which can be described using linear recurrence relation in O(log(n)) time

Apart from these, several Dynamic Programming and greedy Algorithms and a BigInteger class have also been