This repository was created during the study of Introduction to Algorithms, Third Edition By Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein book.
A well-written book with detailed implementation of algorithms.
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
List of algorithms presented in the book.
- Chapter 1.
- Chapter 2.
- Merge sort
- Bubble sort
- Chapter 3.
- Fibonacci numbers
- Chapter 4.
- Maximum subarray problem
- Square matrix multiply
- Strassen algorithm
- Chapter 5.
- Hire assistant problem.
- Birthday problem.
- Chapter 6.
- Chapter 7.
- Chapter 8.
- Chapter 9.
- Chapter 10.
- Chapter 11.
- Hash table
- Hash with open addressing
- Double Hashing
- Perfect hashing
- Chapter 12.
- Chapter 13.
- Chapter 14.
- Order-statistic tree
- Josephus problem
- Chapter 15.
- Rod cutting problem
- Matrix chain multiplication problem
- Longest common subsequence problem
- Optimal binary search tree
- Edit distance
- Chapter 16.
- Activity selection problem.
- Knapsack problem.
- Huffman coding.
- Chapter 17.
- Chapter 18.
- Chapter 19.
- Fibonacci heap
- Chapter 20.
- Van Emde Boas tree
- Chapter 21.
- Disjoining-set data structure
- Disjoining-set forest
- Least common ancestor
- Chapter 22.
- Chapter 23.
- Kruskal's algorithm
- Prim's algorithm
- Chapter 24.
- Chapter 25.
- Floyd-Warshall algorithm
- Johnson's algorithm
- Chapter 26.
- Maximum flow problem
- Ford–Fulkerson algorithm
- Relabel-to-front algorithm
- Chapter 27.
- Fibonacci number using multithreading
- Matrix multiplication using multithreading
- Multithreading Strassen algorithm
- Multithreading merge sort
- Chapter 28.
- LU decomposition
- LUP decomposition
- Invertible matrix
- Chapter 29.
- Simplex algorithm.
- Chapter 30.
- Recursive FFT.
- Iterative FFT.
- Parallel FFT.
- Chapter 31.
- Euclid algorithm.
- Modular exponentiation.
- RSA algorithm.
- Pseudoprime.
- Miller–Rabin primality test.
- Pollard's rho algorithm.
- Binary GCD algorithm.
- Chapter 32.
- String searching algorithm.
- Rabin–Karp algorithm.
- Knuth–Morris–Pratt algorithm.
- Chapter 33.
- Line segment intersection.
- Graham scan.
- Gift wrapping algorithm.
- Chapter 34.
- Chapter 35.
- Approximate vertex cover.
- Approximate travelling salesman problem.
- Greedy set cover.
- Exact subset sum.
Table of complexity of different sorting algorithms:
For plot beautiful performance chart run following command.
python sort/performance.py
Algorithm | Worst case | Average case |
---|---|---|
Insertion Sort | O(n^2) | O(n^2) |
Merge Sort | O(n*ln(n)) | O(n*ln(n)) |
Heap Sort | O(n*ln(n)) | O(n*ln(n)) |
Quick Sort | O(n^2) | O(n*ln(n)) |
Counting Sort | O(k + n) | O(k + n) |
Radix Sort | O(d(k + n)) | O(d(k + n)) |
Bucket Sort | O(n^2) | O(n) |
- Naive matrix multiplication O(n^3)
- Strassen matrix multiplication O(n^2.81)
python matrix/performance.py