MCPcopy
hub / github.com/williamfiset/algorithms

github.com/williamfiset/algorithms @main sqlite

repository ↗ · DeepWiki ↗
3,513 symbols 10,941 edges 329 files 323 documented · 9%
README

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

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

Dynamic Programming

Dynamic Programming Classics

Dynamic Programming Problem Examples

Adhoc

Tiling problems

Geometry

More geometry algorithms

Extension points exported contracts — how you extend this code

InplaceSort (Interface)
(no doc) [25 implementers]
src/main/java/com/williamfiset/algorithms/sorting/InplaceSort.java
Queue (Interface)
@author liujingkun, liujkon@gmail.com @param the type of element held int the queue [4 implementers]
src/main/java/com/williamfiset/algorithms/datastructures/queue/Queue.java
MwpmInterface (Interface)
(no doc) [5 implementers]
src/main/java/com/williamfiset/algorithms/dp/MwpmInterface.java
PrintableNode (Interface)
Node that can be printed [3 implementers]
src/main/java/com/williamfiset/algorithms/datastructures/utils/TreePrinter.java
Stack (Interface)
Stack Interface Defines the core operations for a last-in, first-out (LIFO) data structure. Implementations include arr [3 …
src/main/java/com/williamfiset/algorithms/datastructures/stack/Stack.java

Core symbols most depended-on inside this repo

size
called by 284
src/main/java/com/williamfiset/algorithms/datastructures/stack/Stack.java
get
called by 233
src/main/java/com/williamfiset/algorithms/datastructures/dynamicarray/IntArray.java
insert
called by 219
src/main/java/com/williamfiset/algorithms/datastructures/trie/Trie.java
rangeQuery
called by 202
src/main/java/com/williamfiset/algorithms/datastructures/segmenttree/GenericSegmentTree.java
add
called by 192
src/main/java/com/williamfiset/algorithms/datastructures/set/HSet.java
sort
called by 161
src/main/java/com/williamfiset/algorithms/sorting/InplaceSort.java
put
called by 161
src/main/java/com/williamfiset/algorithms/datastructures/hashtable/HashTableSeparateChaining.java
isEmpty
called by 133
src/main/java/com/williamfiset/algorithms/datastructures/stack/Stack.java

Shape

Method 3,056
Class 425
Function 17
Enum 8
Interface 7

Languages

Java100%
TypeScript1%

Modules by API surface

src/main/java/com/williamfiset/algorithms/graphtheory/analysis/PrimsGraphRepresentationAnaylsis.java51 symbols
src/test/java/com/williamfiset/algorithms/datastructures/segmenttree/GenericSegmentTreeTest.java50 symbols
src/main/java/com/williamfiset/algorithms/strings/LongestCommonSubstring.java47 symbols
src/main/java/com/williamfiset/algorithms/graphtheory/examples/EagerPrimsExample.java42 symbols
src/test/java/com/williamfiset/algorithms/datastructures/linkedlist/LinkedListTest.java36 symbols
src/test/java/com/williamfiset/algorithms/datastructures/balancedtree/AVLTreeTest.java36 symbols
src/main/java/com/williamfiset/algorithms/graphtheory/ChinesePostmanProblem.java35 symbols
src/main/java/com/williamfiset/algorithms/graphtheory/DijkstrasShortestPathAdjacencyListWithDHeap.java34 symbols
src/main/java/com/williamfiset/algorithms/graphtheory/EagerPrimsAdjacencyList.java33 symbols
src/test/java/com/williamfiset/algorithms/datastructures/dynamicarray/IntArrayTest.java32 symbols
src/test/java/com/williamfiset/algorithms/dp/WeightedMaximumCardinalityMatchingTest.java30 symbols
src/test/java/com/williamfiset/algorithms/datastructures/binarysearchtree/BinarySearchTreeTest.java30 symbols

For agents

$ claude mcp add algorithms \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact