Algorithms
A collection of algorithms and data structures
Install / Use
/learn @williamfiset/AlgorithmsREADME
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
Running with Bazel (recommended)
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
- :movie_camera: Balanced Trees
- :movie_camera: Binary Search Tree
- Splay Tree
- :movie_camera: Dynamic Array
- :movie_camera: Fenwick Tree
- Fibonacci Heap
- :movie_camera: Hashtable
- :movie_camera: Linked List
- :movie_camera: Priority Queue
- :movie_camera: Queue
- Segment Tree
- :movie_camera: Sparse Table
- :movie_camera: Stack
- :movie_camera: Suffix Array
- Trie
- :movie_camera: Union Find
Dynamic Programming
Dynamic Programming Classics
- Coin change problem - O(nW)
- Edit distance (iterative) - O(nm)
- Edit distance (recursive) - O(nm)
- :movie_camera: Knapsack 0/1 - O(nW)
- Knapsack unbounded (0/∞) - O(nW)
- Maximum contiguous subarray - O(n)
- Longest Common Subsequence (LCS) - O(nm)
- Longest Increasing Subsequence (LIS) - O(n<sup>2</sup>)
- Longest Palindrome Subsequence (LPS) - O(n<sup>2</sup>)
- :movie_camera: Traveling Salesman Problem (dynamic programming, iterative) - O(n<sup>2</sup>2<sup>n</sup>)
- Traveling Salesman Problem (dynamic programming, recursive) - O(n<sup>2</sup>2<sup>n</sup>)
- Minimum Weight Perfect Matching (iterative, complete graph) - O(n<sup>2</sup>2<sup>n</sup>)
Dynamic Programming Problem Examples
Adhoc
- :movie_camera: Magic Cows
- :movie_camera: [Narrow Art Gallery](https://github.com/williamfiset/Algorithms/blob/master/src/main/java/com/williamfiset/algorithms/dp/ex
Related Skills
ditto-sales-enablement
2Claude Code skill: Generate a complete sales enablement kit (battlecard, objection guide, quote bank, one-pager, pitch narrative, ROI framework, demo script) from a single Ditto research study.
heroku-agentforce-mcp
3This repository has 4 different MCP projects that demonstrates some of the inner workings of the MCP and architectural patterns when integrating with various Agents as well as Agentforce.
dubbl
3A full-featured, open-source alternative to Xero and QuickBooks. It is API-first, developer-friendly, and built for teams that want full control over their financial data.
