|
37 | 37 | <h3>All algorithms implemented in Python - for education 📚</h3> |
38 | 38 | </div> |
39 | 39 |
|
40 | | -Implementations are for learning purposes only. They may be less efficient than the implementations in the Python standard library. Use them at your discretion. |
| 40 | +> **Note**: These implementations are for **learning purposes** only. They may be less efficient than the implementations in the Python standard library. Use them at your discretion. |
| 41 | +
|
| 42 | +--- |
| 43 | + |
| 44 | +### 🌟 Quick Links |
| 45 | + |
| 46 | +[🚀 Get Started](#-getting-started) • [📖 Browse Algorithms](DIRECTORY.md) • [💻 Code Examples](#-usage-examples) • [🤝 Contribute](CONTRIBUTING.md) • [💬 Join Discord](https://the-algorithms.com/discord) |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## 📑 Table of Contents |
| 51 | + |
| 52 | +- [✨ Why Choose This Repository?](#-why-choose-this-repository) |
| 53 | +- [🚀 Getting Started](#-getting-started) |
| 54 | +- [📚 Algorithm Categories](#-algorithm-categories) |
| 55 | +- [💡 Usage Examples](#-usage-examples) |
| 56 | +- [🤝 Contributing](#-contributing) |
| 57 | +- [🌐 Community Channels](#-community-channels) |
| 58 | +- [🎓 Learning Path](#-learning-path) |
| 59 | +- [🛠️ Development Setup](#️-development-setup) |
| 60 | +- [🧪 Testing](#-testing) |
| 61 | +- [📊 Project Stats](#-project-stats) |
| 62 | +- [📖 Resources](#-resources) |
| 63 | +- [🏆 Top Contributors](#-top-contributors) |
| 64 | +- [📜 License](#-license) |
| 65 | +- [💬 Get Help](#-get-help) |
| 66 | +- [⭐ Show Your Support](#-show-your-support) |
| 67 | + |
| 68 | +## ✨ Why Choose This Repository? |
| 69 | + |
| 70 | +- **🎓 Perfect for Learning**: Clean, well-commented code designed specifically for educational purposes |
| 71 | +- **📈 1300+ Implementations**: One of the most comprehensive algorithm collections on GitHub |
| 72 | +- **✅ Quality Assured**: Every algorithm includes tests and passes continuous integration |
| 73 | +- **🌍 Community-Driven**: Thousands of contributors worldwide, actively maintained |
| 74 | +- **📝 Well-Documented**: Detailed docstrings, complexity analysis, and usage examples |
| 75 | +- **🔬 Multiple Domains**: From basic sorting to machine learning, cryptography to computer vision |
| 76 | +- **🚀 Ready to Use**: Copy, learn from, and adapt code for your projects |
| 77 | +- **🎯 Interview Prep**: Perfect resource for coding interviews and competitive programming |
41 | 78 |
|
42 | 79 | ## 🚀 Getting Started |
43 | 80 |
|
| 81 | +### Prerequisites |
| 82 | + |
| 83 | +- Python 3.8 or higher |
| 84 | +- pip (Python package installer) |
| 85 | + |
| 86 | +### Installation |
| 87 | + |
| 88 | +1. Clone the repository: |
| 89 | +```bash |
| 90 | +git clone https://github.com/TheAlgorithms/Python.git |
| 91 | +cd Python |
| 92 | +``` |
| 93 | + |
| 94 | +2. Install dependencies: |
| 95 | +```bash |
| 96 | +pip install -r requirements.txt |
| 97 | +``` |
| 98 | + |
| 99 | +3. Run any algorithm: |
| 100 | +```bash |
| 101 | +python3 sorts/quick_sort.py |
| 102 | +python3 searches/binary_search.py |
| 103 | +``` |
| 104 | + |
| 105 | +### Running Tests |
| 106 | + |
| 107 | +```bash |
| 108 | +pytest |
| 109 | +``` |
| 110 | + |
| 111 | +## 📚 Algorithm Categories |
| 112 | + |
| 113 | +<table> |
| 114 | +<tr> |
| 115 | +<td width="50%"> |
| 116 | + |
| 117 | +**Computer Science Fundamentals** |
| 118 | +- 🗂️ Data Structures (Arrays, Trees, Graphs, Heaps) |
| 119 | +- 🔄 Sorting (Quick, Merge, Heap, Radix, etc.) |
| 120 | +- 🔍 Searching (Binary, Ternary, Jump, etc.) |
| 121 | +- 🔙 Backtracking (N-Queens, Sudoku, Maze) |
| 122 | +- 🌊 Divide and Conquer |
| 123 | +- 💰 Dynamic Programming |
| 124 | +- 🎯 Greedy Algorithms |
| 125 | +- 📊 Graph Algorithms (BFS, DFS, Dijkstra, Floyd-Warshall) |
| 126 | + |
| 127 | +**Mathematics & Science** |
| 128 | +- ➕ Mathematical Algorithms |
| 129 | +- 🔢 Number Theory |
| 130 | +- 📐 Geometry & Computational Geometry |
| 131 | +- 🧮 Linear Algebra & Matrix Operations |
| 132 | +- 📈 Statistics & Probability |
| 133 | +- ⚛️ Physics Simulations |
| 134 | +- 🌍 Geodesy |
| 135 | + |
| 136 | +</td> |
| 137 | +<td width="50%"> |
| 138 | + |
| 139 | +**Machine Learning & AI** |
| 140 | +- 🤖 Machine Learning (Regression, Classification) |
| 141 | +- 🧠 Neural Networks |
| 142 | +- 🧬 Genetic Algorithms |
| 143 | +- 🎲 Fuzzy Logic |
| 144 | +- 📊 Data Mining |
| 145 | + |
| 146 | +**Applied Computer Science** |
| 147 | +- 🔐 Cryptography & Ciphers |
| 148 | +- 🖼️ Computer Vision |
| 149 | +- 🎨 Digital Image Processing |
| 150 | +- 🎵 Audio Filters |
| 151 | +- 🌐 Web Programming |
| 152 | +- 📡 Networking & Data Transfer |
| 153 | +- 🗜️ Data Compression |
| 154 | +- 💹 Financial Algorithms |
| 155 | +- ⚡ Electronics & Circuit Design |
| 156 | + |
| 157 | +</td> |
| 158 | +</tr> |
| 159 | +</table> |
| 160 | + |
| 161 | +📖 See our complete **[DIRECTORY.md](DIRECTORY.md)** for the full list of all 1300+ implementations. |
| 162 | + |
| 163 | +## 💡 Usage Examples |
| 164 | + |
| 165 | +### Quick Start - Sorting |
| 166 | +```python |
| 167 | +from sorts.quick_sort import quick_sort |
| 168 | + |
| 169 | +arr = [64, 34, 25, 12, 22, 11, 90] |
| 170 | +sorted_arr = quick_sort(arr) |
| 171 | +print(sorted_arr) # [11, 12, 22, 25, 34, 64, 90] |
| 172 | +``` |
| 173 | + |
| 174 | +### Binary Search |
| 175 | +```python |
| 176 | +from searches.binary_search import binary_search |
| 177 | + |
| 178 | +sorted_list = [1, 3, 5, 7, 9, 11, 13, 15, 17] |
| 179 | +target = 7 |
| 180 | +index = binary_search(sorted_list, target) |
| 181 | +print(f"Found {target} at index {index}") # Found 7 at index 3 |
| 182 | +``` |
| 183 | + |
| 184 | +### Graph Algorithms - Dijkstra's Shortest Path |
| 185 | +```python |
| 186 | +from graphs.dijkstra import dijkstra |
| 187 | + |
| 188 | +# Graph represented as adjacency list |
| 189 | +graph = { |
| 190 | + 'A': {'B': 1, 'C': 4}, |
| 191 | + 'B': {'C': 2, 'D': 5}, |
| 192 | + 'C': {'D': 1}, |
| 193 | + 'D': {} |
| 194 | +} |
| 195 | + |
| 196 | +distances = dijkstra(graph, 'A') |
| 197 | +print(distances) # {'A': 0, 'B': 1, 'C': 3, 'D': 4} |
| 198 | +``` |
| 199 | + |
| 200 | +### Machine Learning - Linear Regression |
| 201 | +```python |
| 202 | +from machine_learning.linear_regression import LinearRegression |
| 203 | + |
| 204 | +X = [[1], [2], [3], [4], [5]] |
| 205 | +y = [2, 4, 6, 8, 10] |
| 206 | + |
| 207 | +model = LinearRegression() |
| 208 | +model.fit(X, y) |
| 209 | +prediction = model.predict([[6]]) |
| 210 | +print(prediction) # ~12 |
| 211 | +``` |
| 212 | + |
| 213 | +### Cryptography - Caesar Cipher |
| 214 | +```python |
| 215 | +from ciphers.caesar_cipher import encrypt, decrypt |
| 216 | + |
| 217 | +message = "HELLO WORLD" |
| 218 | +encrypted = encrypt(message, shift=3) |
| 219 | +print(encrypted) # "KHOOR ZRUOG" |
| 220 | + |
| 221 | +decrypted = decrypt(encrypted, shift=3) |
| 222 | +print(decrypted) # "HELLO WORLD" |
| 223 | +``` |
| 224 | + |
| 225 | +## 🤝 Contributing |
| 226 | + |
| 227 | +We love contributions! This project exists thanks to all the people who contribute. |
| 228 | + |
44 | 229 | 📋 Read through our [Contribution Guidelines](CONTRIBUTING.md) before you contribute. |
45 | 230 |
|
| 231 | +### How to Contribute |
| 232 | + |
| 233 | +1. Fork the repository |
| 234 | +2. Create a new branch (`git checkout -b feature/algorithm-name`) |
| 235 | +3. Make your changes and commit (`git commit -am 'Add new algorithm'`) |
| 236 | +4. Push to the branch (`git push origin feature/algorithm-name`) |
| 237 | +5. Create a Pull Request |
| 238 | + |
46 | 239 | ## 🌐 Community Channels |
47 | 240 |
|
48 | 241 | We are on [Discord](https://the-algorithms.com/discord) and [Gitter](https://gitter.im/TheAlgorithms/community)! Community channels are a great way for you to ask questions and get help. Please join us! |
49 | 242 |
|
50 | | -## 📜 List of Algorithms |
| 243 | +## 🎓 Learning Path |
| 244 | + |
| 245 | +New to algorithms? Follow this recommended learning path: |
| 246 | + |
| 247 | +1. **Start with Basics**: `sorts/` → `searches/` → `data_structures/` |
| 248 | +2. **Build Foundation**: `recursion/` → `backtracking/` → `divide_and_conquer/` |
| 249 | +3. **Advanced Topics**: `dynamic_programming/` → `graphs/` → `greedy_methods/` |
| 250 | +4. **Specialized Areas**: `machine_learning/` → `ciphers/` → `neural_network/` |
| 251 | + |
| 252 | +Each directory contains a README with explanations and complexity analysis. |
| 253 | + |
| 254 | +## 🛠️ Development Setup |
| 255 | + |
| 256 | +### Using Virtual Environment |
| 257 | +```bash |
| 258 | +# Create virtual environment |
| 259 | +python -m venv venv |
| 260 | + |
| 261 | +# Activate it |
| 262 | +source venv/bin/activate # On Windows: venv\Scripts\activate |
| 263 | + |
| 264 | +# Install dependencies |
| 265 | +pip install -r requirements.txt |
| 266 | +``` |
| 267 | + |
| 268 | +### Using pre-commit hooks |
| 269 | +```bash |
| 270 | +pip install pre-commit |
| 271 | +pre-commit install |
| 272 | +``` |
| 273 | + |
| 274 | +This will automatically format your code and run checks before each commit. |
| 275 | + |
| 276 | +## 🧪 Testing |
| 277 | + |
| 278 | +```bash |
| 279 | +# Run all tests |
| 280 | +pytest |
| 281 | + |
| 282 | +# Run tests for a specific module |
| 283 | +pytest sorts/test_sorts.py |
51 | 284 |
|
52 | | -See our [directory](DIRECTORY.md) for easier navigation and a better overview of the project. |
| 285 | +# Run with coverage |
| 286 | +pytest --cov=. --cov-report=html |
| 287 | +``` |
| 288 | + |
| 289 | +## 📊 Project Stats |
| 290 | + |
| 291 | +- **Total Implementations**: 1300+ algorithms |
| 292 | +- **Lines of Code**: 100,000+ |
| 293 | +- **Contributors**: 1000+ |
| 294 | +- **Stars**: Check the repo! |
| 295 | +- **Programming Language**: Python 3.8+ |
| 296 | + |
| 297 | +## 📖 Resources |
| 298 | + |
| 299 | +- 🌐 [The Algorithms Website](https://the-algorithms.com/) |
| 300 | +- 📚 [Python Algorithm Documentation](https://the-algorithms.com/language/python) |
| 301 | +- 📝 [Contributing Guide](CONTRIBUTING.md) |
| 302 | +- 🤝 [Code of Conduct](https://github.com/TheAlgorithms/.github/blob/master/CODE_OF_CONDUCT.md) |
| 303 | +- 🎥 [Video Tutorials](https://www.youtube.com/c/thealgorithms) |
| 304 | + |
| 305 | +## 🏆 Top Contributors |
| 306 | + |
| 307 | +A huge thanks to all our contributors! This project wouldn't be possible without you. |
| 308 | + |
| 309 | +<a href="https://github.com/TheAlgorithms/Python/graphs/contributors"> |
| 310 | + <img src="https://contrib.rocks/image?repo=TheAlgorithms/Python" /> |
| 311 | +</a> |
| 312 | + |
| 313 | +## 📜 License |
| 314 | + |
| 315 | +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details. |
| 316 | + |
| 317 | +## 💬 Get Help |
| 318 | + |
| 319 | +- 📫 Create an [Issue](https://github.com/TheAlgorithms/Python/issues/new/choose) for bug reports or feature requests |
| 320 | +- 💭 Join our [Discord](https://the-algorithms.com/discord) for discussions |
| 321 | +- 🗨️ Ask questions on [Gitter](https://gitter.im/TheAlgorithms/community) |
| 322 | + |
| 323 | +## ⭐ Show Your Support |
| 324 | + |
| 325 | +If you find this project helpful: |
| 326 | +- Give it a ⭐ star on GitHub |
| 327 | +- Share it with your friends and colleagues |
| 328 | +- Contribute by adding new algorithms or improving existing ones |
| 329 | +- Help us translate documentation |
| 330 | + |
| 331 | +--- |
| 332 | + |
| 333 | +<div align="center"> |
| 334 | + Made with ❤️ by <a href="https://github.com/TheAlgorithms/Python/graphs/contributors">contributors</a> around the 🌍 |
| 335 | + <br> |
| 336 | + <sub>Happy Coding! 🚀</sub> |
| 337 | +</div> |
0 commit comments