Implementation of well-known (and some rare) algorithms, in C++.
✅ = has unit tests
- Backtracking
- Dynamic programming
- Matrix chain multiplication ✅
- Maximum sum contiguous subarray: Kadane's algorithm
- Number theory
- Binomial coefficient ✅
- Euclidean algorithms
- Greatest common divisor (GCD)
- Extended Euclidean algorithm (Bézout coefficients and GCD)
- Fast exponentiation ✅
- Nth Fibonacci number
- Perfect number check ✅
- Prime numbers
- Searching
- Sorting
- String
- Longest common subsequence
- Searching (pattern matching)
To compile the source files, run make all
. Doing so will:
- create executable binaries in sub-directories under the
bin
directory, and - create intermediate build files in sub-directories under the
build
directory.
The sub-directories will be the same as they are under source
.
To compile and run the tests, run make test
. This will compile all the tests (in the same way as described above) and will run them, displaying the results. Note that the test binaries will have .test
at the end of their name.
To remove all of the files created during compilation, run make clean
. You need not do this every time you make some changes to a file and want to recompile it. Just run make all
, and it will re-compile just those files whose contents have changed.
To know what happens in the background when make
runs, you may read the Makefile. For more information on make
, read the GNU make Manual.
If you would like to (and you should) add unit tests for the code you are contributing, or for some of the existing code, read about Adding unit tests for C++ code.
If you want to contribute an algorithm or data structure in C++, make sure to read the C++ Coding Guidelines apart from the general Contributing Guidelines. This will help in ensuring that your code conforms to the style followed in this project.