Codes of the (common and not-so-common) algorithms used in computer science in C/C++. This is an ongoing project and there are many more to come.
Most of the algorithms are implemented in more than one way, using different data-structures and by using different approaches catering both to the naive and the advanced users.
The codes available have been extensivley tested and debugged with large number of testcases varying from small to really big input sizes (to the order of 10^7). The codes are specially built to handle large number of data with efficiency.
Users are welcome to test for themselves using inbuilt test-case generators provided with some of them (ex: quick-sort-test-case-generator).
Even after all these there is always a chance for error/improvement. Users are welcome to provide feedback and comment regarding these.
Users should set-up an environment which supports C/C++ like GNU or IDEs which support C/C++. You can simply compile them and run the executable.
An example is given below for linux environment, open a terminal in the directory in which the code is present and execute the following commands:
// For C codes:
gcc <name of file>
./a.out
// For C++ codes:
g++ <name of file>
./a.out
All codes have predefined input already available in main(), however these can be replaced by external test-cases. Users are welcome to use the testing-debug-template to help read input from an external file / write input to an external file.
List of algorithms (in no specific order) present in the project. Please note that this is only a tentaive list and many more are yet to come.
- Merge Sort (using Hoare-partitioning)
- Merge Sort (using Lomuto-partitioning)
- Quick Sort (using Hoare-partitioning)
- Quick Sort (using Lomuto-partitioning)
- Fisher Yates Shuffling
- i-th Order Statistic (both randomized and deterministic)
- Dijkstra's Shortest Path (2 variants)
- Prim's MST
- Prim's MST using Heap
- DFS & BFS in a Graph
- Hashing
- Krager's Minimum Cut
- Computing Components in a Graph
- Kosaraju's Strongly Connected Components
- Inversion of an Array
- Finding Closest Pair in 1 Dimension
- Finding Closest Pair in 2 Dimension (2 variants)
- Max & Min Heap
- Karatsuba-Multiplication
- Various representation of graphs
Anyone can contribute to this project as much as possible using any language of their choice. Do give proper comments in your code and please maintain the coding style mentioned here.
Let's keep expanding this list of algorithms !
This project is licensed under the MIT License - see the LICENSE file for details