algorithms README

The project's README from github.com/williamfiset/algorithms. As one markdown file: README.md.

License: MIT Bazel Tests README Checker Sponsor

Algorithms & data structures project

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.

🎬 Many of the algorithms and data structures in this repo have companion video explanations on the William Fiset YouTube channel — so if the code alone doesn't click, grab some popcorn and watch the videos!

Running an algorithm implementation

To compile and run any of the algorithms here, you need at least JDK version 8 and Bazel

This project uses Bazel as its build system. Install Bazel by following the official installation guide.

Run a single algorithm like this:

bazel run //src/main/java/com/williamfiset/algorithms/<subpackage>:<ClassName>

For instance:

bazel run //src/main/java/com/williamfiset/algorithms/search:BinarySearch

Run all tests:

bazel test //src/test/...

Run tests for a specific package:

bazel test //src/test/java/com/williamfiset/algorithms/sorting:all

Compiling and running with only a JDK

If you don't want to use Bazel, you can compile and run with just the JDK:

Create a classes folder

cd Algorithms
mkdir classes

Compile the algorithm

javac -sourcepath src/main/java -d classes src/main/java/<relative-path-to-java-source-file>

Run the algorithm

java -cp classes <class-fully-qualified-name>

Example

$ javac -d classes -sourcepath src/main/java src/main/java/com/williamfiset/algorithms/search/BinarySearch.java
$ java -cp classes com.williamfiset.algorithms.search.BinarySearch

Data Structures

Dynamic Programming

Dynamic Programming Classics

Dynamic Programming Problem Examples

Adhoc

Tiling problems

Geometry

More geometry algorithms

Graph theory

Tree algorithms

Network flow

Main graph theory algorithms

algorithms (williamfiset/algorithms)

Searching Database…

Что это такое?Большая open-source подборка классических алгоритмов и структур данных на Java, написанная для того, чтобы показать корректные реализации самым простым и элегантным способом.
Это библиотека, которую я подключаю к своему проекту, или скорее учебный материал?Это скорее справочная подборка, чем готовая библиотека: в README показано, как скомпилировать и запустить каждую реализацию отдельно, так что вы читаете код и копируете то, что нужно.
Как скомпилировать и запустить реализацию? Нужен ли Bazel?Нужен JDK 8 или новее. Bazel — рекомендуемая система сборки для запуска алгоритмов и тестов, но можно обойтись без него: скомпилируйте любой файл обычным javac в папку classes и запустите через java.
Там указана вычислительная сложность каждого алгоритма?Да — почти у каждой записи указана сложность, например O(Elog(V)) для алгоритма Дейкстры или O(nlog(n)) для построения суффиксного массива.
Проект ещё обновляется?Он появился в 2017 году и не переведён в архив, а в репозитории настроены workflow для GitHub Actions (main.yml, readme-url-checker.yml).
Можно скопировать код в свой проект?Да — проект распространяется по лицензии MIT, так что реализации можно использовать, изменять и распространять, в том числе в коммерческих проектах.
Size
1.2 GB
Stars
18.8K
Updated
CommitJun 23
Age
9y
Commits · 90 Days