A collection of algorithms and data structures
Algorithms and data structures are fundamental to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. This repository's goal is to demonstrate how to correctly implement common data structures and algorithms in the simplest and most elegant ways.
This repository is contribution friendly :smiley:. If you'd like to add or improve an algorithm, your contribution is welcome! Please be sure to checkout the Wiki for instructions.
This repository provides algorithm implementations in Java, however there are other forks that provide implementations in other languages, most notably:
To compile and run any of the algorithms here, you need at least JDK version 8. Gradle can make things more convenient for you, but it is not required.
This project supports the Gradle Wrapper. The Gradle wrapper automatically downloads Gradle at the first time it runs, so expect a delay when running the first command below.
If you are on Windows, use
Run a single algorithm like this:
./gradlew run -Palgorithm=.
Alternatively, you can run a single algorithm specifying the full class name
./gradlew run -Pmain=
./gradlew run -Palgorithm=search.BinarySearch
./gradlew run -Pmain=com.williamfiset.algorithms.search.BinarySearch
cd Algorithms mkdir classes
javac -sourcepath src/main/java -d classes src/main/java/
java -cp classes
$ javac -d classes -sourcepath src/main/java src/main/java/com/williamfiset/algorithms/search/BinarySearch.java $ java -cp classes com.williamfiset.algorithms.search.BinarySearch
This repository is released under the MIT license. In short, this means you are free to use this software in any personal, open-source or commercial projects. Attribution is optional but appreciated.