Welcome to the Algorithms repository! We are building a curated, multi-language collection of 248 algorithms with 2,402 implementations across 11 languages, organized by category. Every contribution goes through templates, automated validation, and maintainer review to ensure consistent quality across the entire project.
For more on our project goals, see the README.
The maintainer of the project is Thuvarakan.
- Repository Structure
- How to Contribute
- Code Standards
- PR Requirements
- Quality Bar
- Supported Languages
- Categories
- Scaffold Script
- PR Validation Bot
- Requesting Algorithms or Implementations
- Getting Help
- Contributors
This repository follows a category-first organization. Every algorithm lives under its category, and each algorithm directory contains documentation, test cases, and implementations in one or more languages.
algorithms/
└── sorting/
└── bubble-sort/
├── README.md
├── metadata.yaml
├── tests/
│ └── cases.yaml
├── python/
│ └── bubble_sort.py
├── java/
│ └── BubbleSort.java
└── ...
Each algorithm directory contains:
| File/Directory | Purpose |
|---|---|
README.md |
Educational explanation of the algorithm (overview, steps, complexity, use cases) |
metadata.yaml |
Structured metadata (name, category, complexity, tags, related algorithms) |
tests/cases.yaml |
Test cases with inputs and expected outputs (minimum 5, including edge cases) |
{language}/ |
One subdirectory per language implementation |
-
Check if the algorithm already exists. Browse the
algorithms/directory or search the README table to make sure the algorithm has not already been added. -
Fork the repository and create a branch.
git checkout -b add/{category}/{algorithm-slug} -
Scaffold the algorithm directory. Use the scaffold script to generate all boilerplate:
npm run scaffold -- --name "Algorithm Name" --slug algorithm-slug --category sorting --difficulty intermediateThis creates the full directory structure with template files for
metadata.yaml,README.md,tests/cases.yaml, and empty directories for all 11 languages. -
Fill in
metadata.yaml. Copy the template fromtemplates/metadata-template.yamland fill in all fields:name-- Human-readable algorithm nameslug-- Kebab-case identifier (must match directory name)category-- One of the 14 supported categoriessubcategory-- More specific grouping (optional)difficulty--beginner,intermediate, oradvancedtags-- Searchable keywordscomplexity-- Time (best, average, worst) and space in Big-O notationstable-- Whether the algorithm is stable (true,false, ornullif not applicable)in_place-- Whether the algorithm operates in place (true,false, ornull)related-- Slugs of related algorithmsimplementations-- List of languages with implementationsvisualization--trueorfalse
-
Add
README.md. Copy the template fromtemplates/algorithm-readme-template.md. The README must include all of these sections:- Overview
- How It Works (with a worked example)
- Pseudocode
- Complexity Analysis (table with best/average/worst time and space)
- When to Use / When NOT to Use
- Comparison with Similar Algorithms
- References
-
Add
tests/cases.yaml. Copy the template fromtemplates/test-cases-template.yaml. Requirements:- Minimum 5 test cases
- Must include edge cases (empty input, single element, etc.)
- Must define the
function_signature(name, input types, output type) - All implementations must match this signature
-
Add at least one language implementation. Create a subdirectory for the language (e.g.,
python/) and add your implementation file following the file naming conventions. The function must match the signature defined intests/cases.yaml. -
Run validation.
node scripts/validate-structure.mjs
Fix any errors before submitting.
-
Submit a pull request. Follow the PR requirements below.
-
Find the algorithm directory. Navigate to
algorithms/{category}/{algorithm-slug}/. -
Read the existing
tests/cases.yaml. Understand the function signature and all test cases your implementation must pass. -
Create the language subdirectory.
mkdir algorithms/{category}/{algorithm-slug}/{language} -
Implement the algorithm.
- The function name and signature must match what is defined in
tests/cases.yaml. - Your implementation must pass all test cases.
- Follow the file naming conventions and code standards.
- The function name and signature must match what is defined in
-
Update
metadata.yaml. Add your language to theimplementationslist. -
Submit a pull request.
Each language has its own convention. Use the table below:
| Language | Convention | Example |
|---|---|---|
| Python | snake_case.py |
bubble_sort.py |
| Java | PascalCase.java |
BubbleSort.java |
| C++ | snake_case.cpp |
bubble_sort.cpp |
| C | snake_case.c |
bubble_sort.c |
| Go | snake_case.go |
bubble_sort.go |
| TypeScript | camelCase.ts |
bubbleSort.ts |
| Kotlin | PascalCase.kt |
BubbleSort.kt |
| Rust | snake_case.rs |
bubble_sort.rs |
| Swift | PascalCase.swift |
BubbleSort.swift |
| Scala | PascalCase.scala |
BubbleSort.scala |
| C# | PascalCase.cs |
BubbleSort.cs |
- Match the function signature defined in
tests/cases.yamlexactly. - Write idiomatic code for the language (e.g., use Pythonic patterns in Python, proper error handling in Rust, etc.).
- Document your code with clear comments explaining the logic and key steps.
- Include standard optimizations where applicable (e.g., early termination in bubble sort when no swaps occur in a pass).
- Keep it clean -- no dead code, no debugging statements, consistent formatting.
All pull requests must meet the following criteria before they will be merged:
- Structure validation passes. Run
node scripts/validate-structure.mjsand ensure zero errors. - All test cases pass for every submitted implementation.
README.mdfollows the template with all required sections filled in.metadata.yamlis complete and accurate -- all fields populated, complexity values correct.- Maintainer review required. Every PR is reviewed by a maintainer before merging. Expect feedback on code quality, documentation clarity, and test coverage.
This is a curated repository. We hold contributions to a high standard:
- Implementations must be idiomatic for their language. A Java solution should look like good Java, not transliterated Python.
- Test cases must cover edge cases -- empty inputs, single elements, already-sorted data, negative numbers, large inputs, duplicates, and any other boundary conditions relevant to the algorithm.
- Documentation must be educational and accurate. The README should teach someone how the algorithm works, not just describe it. Complexity analysis must be correct and explained.
This project accepts implementations in the following 11 languages:
- Java
- Python
- C
- C++
- Go
- TypeScript
- Kotlin
- Rust
- Swift
- Scala
- C#
All algorithms are organized into one of the following 14 categories:
| Category | Description |
|---|---|
sorting |
Algorithms that arrange elements in a specific order |
searching |
Algorithms for finding elements or values within data structures |
graph |
Algorithms operating on graph structures (traversal, shortest path, MST, etc.) |
dynamic-programming |
Optimization problems solved by breaking them into overlapping subproblems |
trees |
Algorithms for tree data structures (traversal, balancing, construction) |
strings |
String matching, manipulation, and parsing algorithms |
math |
Number theory, combinatorics, arithmetic, and other mathematical algorithms |
greedy |
Algorithms that make locally optimal choices at each step |
backtracking |
Algorithms that explore all possibilities by building candidates and abandoning those that fail |
divide-and-conquer |
Algorithms that break problems into smaller subproblems, solve them independently, and combine results |
bit-manipulation |
Algorithms that operate directly on binary representations of numbers |
geometry |
Computational geometry algorithms (convex hull, line intersection, etc.) |
cryptography |
Encryption, hashing, and other security-related algorithms |
data-structures |
Implementations and operations on fundamental data structures |
The scaffold script generates all boilerplate for a new algorithm:
npm run scaffold -- --name "Algorithm Name" --slug algorithm-name --category sorting --difficulty intermediateThis creates:
algorithms/{category}/{slug}/metadata.yaml-- Pre-filled with your valuesalgorithms/{category}/{slug}/README.md-- Template with all required sectionsalgorithms/{category}/{slug}/tests/cases.yaml-- Template with 5 test case slots- Empty directories for all 11 languages
Run npm run scaffold -- --help for full usage details.
When you open a pull request, a GitHub Action automatically validates any modified algorithm directories. It checks:
metadata.yamlexists with all required fields (name, slug, category, difficulty, complexity)README.mdexiststests/cases.yamlexists with at least 1 test case- Category is one of the 14 valid categories
- Difficulty is beginner, intermediate, or advanced
The bot posts a comment on your PR summarizing validation results. Fix any reported errors before requesting review.
If you want to request a new algorithm or a language implementation without contributing code yourself, use the issue templates:
- Request a new algorithm -- Specify the algorithm name, category, difficulty, and description
- Request a language implementation -- Specify which algorithm needs an implementation in which language
If you have questions or need guidance:
- Open an issue on the Issues page
- Check existing issues and pull requests for context
- Review the templates in the
templates/directory for examples of what is expected
Thanks to everyone who has contributed to this repository.
- Thuvarakan
- christianbender
- octamois
- abdatta
- Astrophilic
- GayanSandaruwan
- srpurwaha201
- adityadavera
- AtoMc
- AbhiTaker
- youssefAli11997
- gionuno
- lavalojan
- ldhnam
- Sudeepa14
- zskamljic
- gabrielcerteza
- sarthak-sopho
- Fcmam5
- ErangaD
- fenilgandhi
- Technophile7
- r-o-k-u-r-o-u
- pabe94
- IshamMohamed
- maaz93
- melzareix
- causztic
- ranjanbinwani
- buihaduong
- Texla
- prateekpandey14
- riktimmondal
- C2P1
- Pritom14
- k-alkiek
- Crowton
- bansalraghav
- tanya-vedi
- Decoys-out
- xiroV
- jourdanrodrigues
- vicennial
- ms10398
- pratik1998
- bituka
- disc
- Geokats
- maddaladivya
- phoebeclarke
- imiordanov
- Samir55
- Hayaan
- vsk4
- CodeBySid
- nishankbhati
- LegendL3n
- jeroentjo
- alok760
- sachincool
- ayush9398
- sagarkar10
- Haxk20
- sagarchoudhary96
- engrravijain
- trimble
- bamsarts
- Savithri123
- amlaanb
- Kurolox
- DrBanner97
- j3rrywan9
- adikul30
- vn17
- Priyansh2
- cielavenir
- ChaituVR
- hyerra
- fabvit86
- mekisiel
- tushar-dtu
- AymanASamyM
- nicktheway
- arunpyasi
- Akos Kovacs
- AtoMc
- robertmihai26
- Gowtham R
- SrGrace
- d-grossman
- javmonisu
- Nikita
- PlatanoBailando
- lena15n
- stripedpajamas
- Renan Vichetti
- pranjalrai
- stuxxnet
- BurnzZ
- FernandaOchoa
- npcoder2k14
- Jaernbrand
- DiegoVicen
- Ashwin-Kapes
- Santhosh Kumar
- Judar Lima
- Jhalaa
- Maaz Qureshi
- Utkarsh
- langlk
- Anat Portnoy
- Leandro Nunes - lnfnunes
- syam3526
- churrizo
- Aniket Joshi
- kuldeepdadhich
- HimanshuAwasthi95
- Shaon
- Chinmay Chandak
- Suman Chaurasia
- Patrick Fischer
- ServinDC
- Piersdb
- Irshad Ismayil
- BrianChen
- S Ramakrishnan
- Atalanttore
- Anto26
- p-avital
- neddstarkk
- h3r0complex
- vzsky
- raphaelmeyer
- jonasbn
- Aman Kumar
- Esci92
- ir2010
- Cc618
- Md Azharuddin
- Jatin7385
- Rhuancpq
- Omkarnath