Guide · Open source
How to use williamfiset/algorithms: clone, build and run Java algorithms
Updated · written with AI from the project's own documentation and checked against our catalogue data
williamfiset/algorithms is an MIT-licensed collection of Java implementations of common algorithms and data structures, including trees, heaps, queues, hash tables and dynamic programming problems. This guide shows you how to clone the repository, run a single algorithm, and run the test suite, using either Bazel or only a JDK. By the end you will be able to find an implementation and run it on your own machine.
Quick start
- 1Install the prerequisites. Make sure you have JDK 8 or newer. Install Bazel too if you want the recommended build workflow.
- 2Clone the repository. Run git clone on the williamfiset/algorithms repository to get the source files.
- 3Pick an algorithm. Browse the Data Structures and Dynamic Programming sections of the README and open the source file you want.
- 4Run it with Bazel or javac. Use bazel run with the target path, or compile with javac -d classes and run it with java -cp classes.
- 5Run the tests. Run bazel test //src/test/... to test the whole project, or narrow the path to one package.
What you need before you start
The README says you need at least JDK version 8 to compile and run any of the algorithms. Bazel is the project's recommended build system, but it is optional if you are willing to compile with the JDK directly.
Install Bazel by following the official installation guide linked from the README if you want the recommended workflow.
- JDK 8 or newer (required)
- Bazel (recommended), or just a JDK for the simpler path
Clone the repository
Download the source with git. The command below is the one given in the README.
git clone https://github.com/williamfiset/algorithmsRun a single algorithm with Bazel
Bazel targets follow the pattern shown in the README, where the subpackage and class name are filled in. The README's example runs the binary search implementation in the search package.
Run all tests with Bazel using the command below, or limit the test run to one package by changing the path.
bazel run //src/main/java/com/williamfiset/algorithms/search:BinarySearchCompile and run with only a JDK
If you do not want to install Bazel, compile the source file with javac, pointing -sourcepath at the source root so dependencies resolve. Then run the compiled class with java using the classes folder on the classpath.
The README's full example is shown below.
- Create a classes folder in the repository root before compiling.
- Compile with javac, then run with java -cp classes and the fully qualified class name.
javac -d classes -sourcepath src/main/java src/main/java/com/williamfiset/algorithms/search/BinarySearch.javaFind the implementation you need
The README groups entries under Data Structures and Dynamic Programming. Each entry links to a source file, so you can open it and read the implementation directly.
Some entries also link to video explanations by the author on YouTube. Watch the video alongside the code if the code alone is hard to follow.
Some variants are labelled by their trade-offs, for example integer-only fixed-size stacks and queues, or generic linked-list versions. Read the label to pick the one that fits your use.
- Data structures include balanced trees, binary search tree, dynamic array, Fenwick tree, Fibonacci heap, hash tables, linked list, priority queues, queue, segment tree, sparse table, stack, suffix array, trie and union find.
- Dynamic programming classics include coin change, edit distance, knapsack, maximum subarray, longest common subsequence, longest increasing subsequence and longest palindrome subsequence.
Use it as a reference, not a production library
The README frames these files as demonstrations of how to implement each structure simply and correctly. They are not presented as a supported library you can drop into a production system.
If you need a maintained library, look at the comparable projects, such as The Algorithms (TheAlgorithms/Java), or the Sedgewick and Wayne companion code.
What people use it for
- Studying how a hash table with separate chaining differs from one using linear probing.
- Comparing your own heap or priority queue code against a reference implementation.
- Following a video explanation on YouTube while reading the matching Java source file.
- Working through dynamic programming problems such as knapsack or edit distance in Java.
Frequently asked questions
Is williamfiset/algorithms free to use?
Yes. The repository is licensed under the MIT License, as shown in the README badge. Check the license file in the repository for the full terms.
What do I need to install to run it?
The README says you need at least JDK 8 to compile and run the algorithms. Bazel is recommended but optional, since you can compile with javac alone.
Can I run it without Bazel?
Yes. The README gives a JDK-only path: create a classes folder, compile with javac -sourcepath src/main/java -d classes, then run with java -cp classes and the fully qualified class name.
Is this code production-ready?
No. The README frames the code as demonstrations of how to implement algorithms correctly and simply, not as a supported library. Use a maintained library for production work.
Does it work with languages other than Java?
No. The primary language is Java and the implementations are written in Java only, so readers who do not use Java will not get much from it.
What are good alternatives?
The comparable projects listed include other Java algorithm collections, The Algorithms (TheAlgorithms/Java), and Sedgewick and Wayne algorithms companion code. Compare them against this repository by topic and by how they are explained.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
williamfiset/algorithms suits students learning data structures and algorithms in Java, and developers who want a clear reference implementation to compare against, especially with video explanations alongside. If you need a production-ready, drop-in library or you do not work in Java, pick a different project such as The Algorithms (TheAlgorithms/Java).
Install options & downloads