█▀▀ █▀█ ▄▀█ █▀█ █░█ ▀█▀ █░█ █▀▀ █▀█ █▀█ █▄█
█▄█ █▀▄ █▀█ █▀▀ █▀█ ░█░ █▀█ ██▄ █▄█ █▀▄ ░█░
█▀▀ █▀█ ▄▀█ █▀█ █░█ ▀█▀ █░█ █▀▀ █▀█ █▀█ █▄█
█▄█ █▀▄ █▀█ █▀▀ █▀█ ░█░ █▀█ ██▄ █▄█ █▀▄ ░█░
- Graph Traversal
- Single Source Shortest Path (SSSP)
- All Pair Shortest Path (APSP)
- Minimum Spanning Tree
- Cycle
- Cycle Check
- Unirected Graph
- Directed graph
- Odd Cycle existence / Bipartite / Bicolorable check
- Cycle Check
- Articulation
- Euler Tour
- DP
- Binary Lifting
- Network Flow
- Max Flow
- Techniques
- Miscellaneous
- Tree Diameter (BFS / DFS)
- Topological Sort
- Strongly Connected Component (SCC)
- Tree Centroid
█▄░█ █░█ █▀▄▀█ █▄▄ █▀▀ █▀█ ▀█▀ █░█ █▀▀ █▀█ █▀█ █▄█
█░▀█ █▄█ █░▀░█ █▄█ ██▄ █▀▄ ░█░ █▀█ ██▄ █▄█ █▀▄ ░█░
█▄░█ █░█ █▀▄▀█ █▄▄ █▀▀ █▀█ ▀█▀ █░█ █▀▀ █▀█ █▀█ █▄█
█░▀█ █▄█ █░▀░█ █▄█ ██▄ █▀▄ ░█░ █▀█ ██▄ █▄█ █▀▄ ░█░
- Power & Modulus
- Extended Euclidean Algorithm
- nCr
- Sieve of Eratosthenes
- General Sieve : O( N log(logN) ) , Memory : O(N)
- Bit Sieve : O( N log(logN) ) , Memory : N bit
- Segmented Sieve : O( (R-L+1) log(logR) + sqrt(R) log(log(sqrt(R))) ) , Memory : O(R-L+1)
- Prime Factorization
- Using all primes : O( (sqrt(N)/log(sqrt(N)) * logN )
- Using only smallest prime factor : O(logN)
- Prime Factorization in a range [L,R] O( (R-L) * logN ) [Optimized]
- Divisors
- Euler Totient
- Linear Diophantine
- Highest Composite Number
- Factorials
- Number of digits in N factorial
- Prime Factorization of N Factorial O(N*log(N))
- Find the first K digits of N!
- Chinese Remainder Theorem
█▀ ▀█▀ █▀█ █ █▄░█ █▀▀
▄█ ░█░ █▀▄ █ █░▀█ █▄█
█▀ ▀█▀ █▀█ █ █▄░█ █▀▀
▄█ ░█░ █▀▄ █ █░▀█ █▄█
- String Hashing
- Suffix Array : O( NlogN )
- Longest Common Prefix (LCP) Array Construction : O(N)
- Prefix Function (KMP ALgorithm) : O(N)
█▀█ █▀▀ █▀▀ █░█ █▀█ █▀ █ █▀█ █▄░█ ▄▀█ █▄░█ █▀▄
█▀▄ ██▄ █▄▄ █▄█ █▀▄ ▄█ █ █▄█ █░▀█ █▀█ █░▀█ █▄▀
█▄▄ ▄▀█ █▀▀ █▄▀ ▀█▀ █▀█ ▄▀█ █▀▀ █▄▀ █ █▄░█ █▀▀
█▄█ █▀█ █▄▄ █░█ ░█░ █▀▄ █▀█ █▄▄ █░█ █ █░▀█ █▄█
█▀█ █▀▀ █▀▀ █░█ █▀█ █▀ █ █▀█ █▄░█ ▄▀█ █▄░█ █▀▄
█▀▄ ██▄ █▄▄ █▄█ █▀▄ ▄█ █ █▄█ █░▀█ █▀█ █░▀█ █▄▀
█▄▄ ▄▀█ █▀▀ █▄▀ ▀█▀ █▀█ ▄▀█ █▀▀ █▄▀ █ █▄░█ █▀▀
█▄█ █▀█ █▄▄ █░█ ░█░ █▀▄ █▀█ █▄▄ █░█ █ █░▀█ █▄█
█▄▄ █ ▀█▀
█▄█ █ ░█░
█▄▄ █ ▀█▀
█▄█ █ ░█░
█▀ █▀▀ ▄▀█ █▀█ █▀▀ █░█
▄█ ██▄ █▀█ █▀▄ █▄▄ █▀█
▀█▀ █▀▀ █▀▀ █░█ █▄░█ █ █▀█ █░█ █▀▀
░█░ ██▄ █▄▄ █▀█ █░▀█ █ ▀▀█ █▄█ ██▄
█▀ █▀▀ ▄▀█ █▀█ █▀▀ █░█
▄█ ██▄ █▀█ █▀▄ █▄▄ █▀█
▀█▀ █▀▀ █▀▀ █░█ █▄░█ █ █▀█ █░█ █▀▀
░█░ ██▄ █▄▄ █▀█ █░▀█ █ ▀▀█ █▄█ ██▄
-
Fenwick Tree / Binary Indexed Tree
- 1D BIT
point update : O(logN) prefix sum array update : O(logN)
- Point Update , Range Query , lower_bound , upper_bound
lower_bound , upper_bound -------------------------- binary search - O( (logN)^2 ) binary lifting - O(logN)
- Range Update , Point Query
- Point Update , Range Query , lower_bound , upper_bound
- 2D BIT
point update : O( (logN)^2 ) 2D prefix sum array update : O( (logN)^2 )
- 1D BIT
-
Recursive Segment Tree
- Non Lazy (Point Update , Range Query)
build : O(N) update , query : O(logN)
- Range Sum ( Possible Variations : Range [ Multiplication , Min , Max , GCD , LCM , and , or , xor ] )
- Maximum Prefix Sum & Maximum Suffix Sum & Maximum Contiguous SubArray Sum
- Lazy (Range Update , Range Query)
build : O(N) update , query : O(logN)
- Merge Sort Tree
- Range Query
build : O( NlogN ) query : O( (logN)^2 ) memory : O( NlogN )
- Point Update , Range Query
build : O( N (logN)^2 ) update , query : O( (logN)^2 ) memory : O( NlogN )
- Range Query
- Non Lazy (Point Update , Range Query)
-
Iterative Segment Tree
- Non Lazy
build : O(N) update , query : O(logN)
- Point Update , Range Query
( Possible Variations : Range [ Multiplication , Min , Max , GCD , LCM , and , or , xor ] ) - Range Update , Point Query
- Point Update , Range Query
- Non Lazy
-
Treap
-
Hash Table
-
Sparse Table
- Range Sum Query : O(logN)
- RMQ : O(1)
-
Mo's Algorithm (Square Root Decomposition)
Total Complexity : O ( (N+Q)F * sqrt(N) ) where O(F) is the complexity of add and remove function
-
Suffix Array
-
STL
-
Policy Based Data Structure
- Set
- Multiset
- Implementation 1 (erase doesn't work)
- Implementation 2
- LCS Variant
- LIS Variant
- Longest Increasing Subsequence
- O(N^2)
- O( NlogN ) Binary Search
- O( NlogN ) Segment Tree
- Longest Bitonic Subsequence
- Increasing Subsequence with Maximum Sum
- Longest Increasing Index-Dividing Subsequence
- Longest Common Increasing Subsequence
- Longest Increasing Subsequence
- Coin Change
- Matrix Variant
- Knapsack Variant
- Digit DP Variant
- Bitmask DP
- Miscellaneous
-
Operator Overloading for sorting / STL Data Structure
-
Integer Root
- Square Root (Binary Search) (Modifiable to nth Root)
- Fast Square & Cube Root
-
Geometry Template
If you like my work, you can also support me by buying me a cup of coffee!
Computer Science & Engineering Department , BUET