Welcome to the world of Algorithms.
This repository provides commonly used algorithms according to Introduction to Algorithms. Codes are implemented in Java, since it's a functional and flexible language, which can clearly show the principles of the algorithms.
As you know, the best way of mastering an algorithm is implementing it. But before that, you need to understand how it works. We have a great book Introduction to Algorithms which tells us about that. However, it's not always smooth to catch the point. What we did here is providing an easy-to-understand implementation, in which you can debug step-by-step. Then grasp the main idea of the algorithm by careful observation.
We created the most intuitive demos for each algorithm. Just run it, the core principle will flash on you at once.
We support Gitpod as online coding platform, you can try it here.
You can use either Intellij IDEA or Gradle to build and test the code locally. But you can only use Gradle as build tool online since Gitpod is using VSCode.
We encourage you to open the project with IntelliJ IDEA, which can provide more flexible and powerful debug experiences.
Start IntelliJ IDEA, click [Open], choose the cloned Algorithms
directory,
confirm by clicking [OK]. Then you will be able to see the project structure.
To run a demo of an algorithm, please right-click the source file, choose [Run '<className>.main()'].
To run all tests, please right-click the test
folder from the Project window, choose [Run 'All Tests'].
If you don't have Intellij IDEA installed or if you are using Gitpod, it's also convenient to build and test with Gradle.
You don't need to have Gradle installed, gradlew
script will download a proper version for you
during the first run.
To run a demo of an algorithm, use command like
./gradlew run -PclassName='<package>.<className>'
For example, run BFPRT algorithm like
./gradlew run -PclassName='select.BFPRT'
To run all tests, use command like
./gradlew test
To help people understand the core concept of each algorithm, we provided multiple resources.
Except for code, you can click the book
and blog
links for more information.
We highly encourage you to contribute to this project, especially if you are a beginner to algorithms. Read this Contributing Guideline to learn more.
Please create an issue or send E-mail to [email protected].