The definitive, open-source collection of all algorithms implemented in Python.
A collaborative educational project dedicated to providing clear, executable, and well-documented examples for fundamental and advanced computer science algorithms.
Metric | Status |
---|---|
Stars | |
Forks | |
Contributors | 1,250+ Active Community Members |
License | |
Code Style | |
Ready-to-Code |
This repository is an invaluable resource for:
- Students: To see working examples of algorithms learned in class.
- Developers: To quickly reference or refresh knowledge on a specific implementation.
- Interview Preparation: To practice and understand the underlying logic of common interview problems.
Our Core Philosophy: Clarity over Performance. Implementations prioritize readability and educational value. They are not optimized for production-grade speed.
The project is meticulously organized into folders, each representing a core domain in computer science.
Domain | Example Topics |
---|---|
Data Structures | Linked Lists, Trees, Heaps, Hash Maps |
Searching & Sorting | Binary Search, Bubble Sort, Merge Sort, Quickselect |
Mathematics | Number Theory, Prime Sieve, Matrix Operations, Geometry |
Advanced CS | Dynamic Programming, Greedy Methods, Divide and Conquer |
Graph Theory | BFS, DFS, Dijkstra's, Kruskal's, Network Flow |
Security & Privacy | Ciphers (Caesar, Vigenere), Hashes (SHA, MD5) |
Modern Tech | Machine Learning, Computer Vision, Blockchain, Quantum Computing |
➡️ Explore All Algorithms: View the full, categorized list in our DIRECTORY.md.
- Python 3.8+
- (Optional but Recommended) A Python virtual environment.
Clone the repository and install necessary dependencies:
# 1. Clone the repository
git clone [https://github.com/TheAlgorithms/Python.git](https://github.com/TheAlgorithms/Python.git)
cd Python
# 2. Install dependencies (We recommend 'uv' for speed)
# pip install uv
# uv sync
# OR using pip
pip install -r requirements.txt
Running an Example
Algorithms are designed to be run directly for testing. Many include doctests for built-in verification.
Bash
# Example: Running the Fibonacci sequence algorithm
python maths/fibonacci_sequence.py
# Example: Running a Graph algorithm
python graphs/depth_first_search.py
This is a 100% community-driven project. Your contributions are the lifeblood of this repository!
How to Get Involved Read the Guidelines: Start with the comprehensive CONTRIBUTING.md for a step-by-step guide.
Find an Issue: Look for open issues labeled good first issue if you're new, or tackle a high-priority bug or missing algorithm.
Submit a Pull Request (PR): Ensure your code is clean, well-commented, and adheres to the Black code style standard.
Your contribution helps millions learn computer science!
Need help, have a suggestion, or just want to discuss an algorithm? Join our vibrant community!
Platform Link Purpose Discord Join our Server Real-time chat, quick help, and contribution coordination. Gitter Join our Chat General discussion and support channel.
Export to Sheets
Do not use this code in a high-performance or production environment. For optimal performance in a production setting, rely on the optimized functions within Python's Standard Library or well-established third-party libraries.
This project is open source and available under the MIT License.