
algorithms
Readable Python implementations of common data structures and algorithms, for learning.
- Stars
- 25.6k
- Forks
- 4.7k
- Licence
- MIT
- Language
- Python
- Last update
- 1 months ago
- Type
- Library
What it is
This is a collection of data structure and algorithm implementations written in Python 3. Each file is meant to be read and learned from, and the README says files include docstrings, type hints, and complexity notes. It can also be installed with pip and imported into your own code.
- Run merge_sort, binary_search, or dijkstra on sample data to see how they behave
- Read the source of a data structure such as a BinaryHeap or Trie alongside its docstrings
- Import a helper like permute or knuth_morris_pratt into a small script
- Run the included test suite with python -m pytest tests/ to check behavior
Great for
- Students studying data structures and algorithms
- Developers reviewing how a classic algorithm works in Python
- Preparing for coding interviews or competitive programming practice
- Looking up a reference implementation of a specific structure, such as a trie or red-black tree
Not ideal for
- Production systems that need heavily tested, performance-tuned libraries, since the README emphasizes clarity over optimization
- Non-Python projects, because all implementations are in Python
How to get it
- 1
Install with a package manager
You'll need: Python 3
Install from PyPI
pip install algorithms - 2
Run it
- Install the package with pip install algorithms
- Open a Python shell and run: from algorithms.sorting import merge_sort
- Call print(merge_sort([38, 27, 43, 3, 9, 82, 10])) and check the output
- Optionally, clone the repository and run python -m pytest tests/
- 3
Get the most out of it
- Read the docstrings and complexity notes in each module to compare approaches
- Use the Project Structure section in the README to find topics by folder
- Step through the examples in the README, such as Dijkstra's shortest path, with your own inputs
- Check the Data Structures table to find the class names and module files for each structure
Downloads
Strengths
- Covers a wide range of topics, from sorting and graphs to segment trees and tries, organized into clear folders
- Each file is described as self-contained with docstrings and complexity notes, which suits learning
- Available on PyPI and licensed under MIT, so it is easy to install and reuse
Trade-offs
- The README describes its goal as minimal, clean examples, so it is not a substitute for optimized or battle-tested libraries
- The README excerpt provided is truncated, so the full list of features and their maturity is not confirmed here
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| algorithms (this) | 25.6k | Library | beginner | 1 months ago | Students studying data structures and algorithms |
| Java | 66.7k | Learning resource | beginner | 4 days ago | Students learning algorithms and data structures in Java |
| C-Plus-Plus | 34.8k | Learning resource | intermediate | 1 months ago | Students learning algorithms and data structures in C++ |
| javascript-algorithms | 197k | Learning resource | beginner | 3 months ago | Students learning core computer science concepts in JavaScript |
| interviews | 65.5k | Learning resource | beginner | 1.5 years ago | Students preparing for their first software engineering interviews |
| algorithm-visualizer | 49.4k | App | beginner | 2.4 years ago | Students learning sorting, searching, or data structures for the first time |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.