|
1 | | -# The Algorithms - Java |
| 1 | +<div align="center"> |
| 2 | + |
| 3 | +# π· The Algorithms - Java |
| 4 | + |
| 5 | +<img src="https://upload.wikimedia.org/wikipedia/en/3/30/Java_programming_language_logo.svg" alt="Java Logo" width="200"/> |
| 6 | + |
| 7 | +### All algorithms implemented in Java (for educational purposes) |
2 | 8 |
|
3 | 9 | [](https://github.com/TheAlgorithms/Java/actions/workflows/build.yml) |
4 | 10 | [](https://codecov.io/gh/TheAlgorithms/Java) |
5 | 11 | [](https://discord.gg/c7MnfGFGa6) |
6 | 12 | [](https://gitpod.io/#https://github.com/TheAlgorithms/Java) |
7 | 13 |
|
| 14 | +[](https://gitpod.io/#https://github.com/TheAlgorithms/Java) |
8 | 15 |
|
9 | | -You can run and edit the algorithms, or contribute to them using Gitpod.io (a free online development environment) with a single click. |
| 16 | +--- |
10 | 17 |
|
11 | | -[](https://gitpod.io/#https://github.com/TheAlgorithms/Java) |
| 18 | +**[π Explore Algorithms](DIRECTORY.md)** β’ **[π€ Contributing](CONTRIBUTING.md)** β’ **[π¬ Community](https://discord.gg/c7MnfGFGa6)** |
| 19 | + |
| 20 | +</div> |
| 21 | + |
| 22 | +<br> |
| 23 | + |
| 24 | +``` |
| 25 | +βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| 26 | +β β |
| 27 | +β π Educational implementations of algorithms in Java β |
| 28 | +β π― Focus on code clarity and learning β |
| 29 | +β π§ͺ Comprehensive test coverage β |
| 30 | +β π Well-documented with JavaDoc β |
| 31 | +β β |
| 32 | +βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| 33 | +``` |
| 34 | + |
| 35 | +## π Overview |
| 36 | + |
| 37 | +This repository contains **Java implementations** of common algorithms and data structures. These implementations are for **learning purposes** and prioritize code clarity over performance. They may be less efficient than the Java standard library. |
| 38 | + |
| 39 | +<details> |
| 40 | +<summary><b>π What's Inside?</b></summary> |
| 41 | + |
| 42 | +<br> |
| 43 | + |
| 44 | +| Feature | Description | |
| 45 | +|---------|-------------| |
| 46 | +| π **Clean Code** | Readable implementations with clear variable names | |
| 47 | +| π§ͺ **Test Coverage** | JUnit test coverage for most algorithms | |
| 48 | +| π **Documentation** | JavaDoc comments with time/space complexity | |
| 49 | +| β **Modern Java** | Leverages Java 21 features | |
| 50 | +| ποΈ **Organized** | Algorithms grouped by category | |
| 51 | + |
| 52 | +</details> |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## π Getting Started |
| 57 | + |
| 58 | +<table> |
| 59 | +<tr> |
| 60 | +<td width="50%"> |
| 61 | + |
| 62 | +### π Prerequisites |
| 63 | + |
| 64 | +```bash |
| 65 | +β Java 21+ |
| 66 | +π¦ Maven 3.6+ |
| 67 | +``` |
| 68 | + |
| 69 | +</td> |
| 70 | +<td width="50%"> |
| 71 | + |
| 72 | +### β‘ Quick Setup |
| 73 | + |
| 74 | +```bash |
| 75 | +git clone https://github.com/TheAlgorithms/Java.git |
| 76 | +cd Java |
| 77 | +mvn clean compile |
| 78 | +mvn test |
| 79 | +``` |
| 80 | + |
| 81 | +</td> |
| 82 | +</tr> |
| 83 | +</table> |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## π‘ Usage Examples |
| 88 | + |
| 89 | +<div align="center"> |
| 90 | + |
| 91 | +```mermaid |
| 92 | +graph LR |
| 93 | + A[Import Algorithm] --> B[Call Method] |
| 94 | + B --> C[Get Result] |
| 95 | + style A fill:#e1f5ff |
| 96 | + style B fill:#fff3e0 |
| 97 | + style C fill:#e8f5e9 |
| 98 | +``` |
| 99 | + |
| 100 | +</div> |
| 101 | + |
| 102 | +All algorithms are implemented as static methods. Import and use them directly: |
| 103 | + |
| 104 | +<table> |
| 105 | +<tr> |
| 106 | +<td width="50%"> |
| 107 | + |
| 108 | +**π Dynamic Programming** |
| 109 | +```java |
| 110 | +import com.thealgorithms.dynamicprogramming.Fibonacci; |
| 111 | + |
| 112 | +int fib = Fibonacci.fibonacci(10); // 55 |
| 113 | +``` |
| 114 | + |
| 115 | +**π Sorting** |
| 116 | +```java |
| 117 | +import com.thealgorithms.sorts.QuickSort; |
| 118 | + |
| 119 | +int[] array = {64, 34, 25, 12, 22, 11, 90}; |
| 120 | +QuickSort.quickSort(array, 0, array.length - 1); |
| 121 | +``` |
| 122 | + |
| 123 | +</td> |
| 124 | +<td width="50%"> |
| 125 | + |
| 126 | +**π Graph Algorithms** |
| 127 | +```java |
| 128 | +import com.thealgorithms.datastructures.graphs.DijkstraAlgorithm; |
| 129 | + |
| 130 | +int[][] graph = {{0, 4, 0}, {4, 0, 8}, {0, 8, 0}}; |
| 131 | +DijkstraAlgorithm dijkstra = new DijkstraAlgorithm(3); |
| 132 | +int[] distances = dijkstra.run(graph, 0); |
| 133 | +``` |
| 134 | + |
| 135 | +**π¦ Data Structures** |
| 136 | +```java |
| 137 | +import com.thealgorithms.datastructures.stacks.BalancedBrackets; |
| 138 | + |
| 139 | +boolean isBalanced = BalancedBrackets.isBalanced("{[()]}"); |
| 140 | +``` |
| 141 | + |
| 142 | +</td> |
| 143 | +</tr> |
| 144 | +</table> |
| 145 | + |
| 146 | +--- |
| 147 | + |
| 148 | +## π Algorithm Categories |
| 149 | + |
| 150 | +<div align="center"> |
| 151 | + |
| 152 | +``` |
| 153 | +βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| 154 | +β ALGORITHM CATEGORIES β |
| 155 | +βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| 156 | +``` |
| 157 | + |
| 158 | +</div> |
| 159 | + |
| 160 | +<table> |
| 161 | +<tr> |
| 162 | +<td width="50%" valign="top"> |
| 163 | + |
| 164 | +### π Sorting & Searching |
| 165 | +``` |
| 166 | +βββ Binary Search |
| 167 | +βββ Linear Search |
| 168 | +βββ Jump Search |
| 169 | +βββ Quick Sort |
| 170 | +βββ Merge Sort |
| 171 | +βββ Heap Sort |
| 172 | +βββ Radix Sort |
| 173 | +``` |
| 174 | + |
| 175 | +### π³ Data Structures |
| 176 | +``` |
| 177 | +βββ Trees |
| 178 | +β βββ BST |
| 179 | +β βββ AVL |
| 180 | +β βββ Red-Black |
| 181 | +βββ Graphs |
| 182 | +β βββ DFS / BFS |
| 183 | +β βββ Dijkstra |
| 184 | +β βββ Bellman-Ford |
| 185 | +βββ Collections |
| 186 | + βββ Stacks |
| 187 | + βββ Queues |
| 188 | + βββ Heaps |
| 189 | +``` |
| 190 | + |
| 191 | +</td> |
| 192 | +<td width="50%" valign="top"> |
| 193 | + |
| 194 | +### π― Algorithm Techniques |
| 195 | +``` |
| 196 | +βββ Dynamic Programming |
| 197 | +β βββ Knapsack |
| 198 | +β βββ LCS |
| 199 | +β βββ Edit Distance |
| 200 | +βββ Greedy Algorithms |
| 201 | +βββ Backtracking |
| 202 | +β βββ N-Queens |
| 203 | +β βββ Sudoku Solver |
| 204 | +βββ Divide & Conquer |
| 205 | +``` |
| 206 | + |
| 207 | +### π Other Topics |
| 208 | +``` |
| 209 | +βββ Cryptography & Ciphers |
| 210 | +βββ Mathematical Algorithms |
| 211 | +βββ String Manipulation |
| 212 | +βββ Bit Operations |
| 213 | +βββ Audio Processing |
| 214 | +``` |
| 215 | + |
| 216 | +</td> |
| 217 | +</tr> |
| 218 | +</table> |
| 219 | + |
| 220 | +<div align="center"> |
| 221 | + |
| 222 | +π **[View Complete Directory β](DIRECTORY.md)** |
| 223 | + |
| 224 | +</div> |
| 225 | + |
| 226 | +--- |
| 227 | + |
| 228 | +## π€ Contributing |
| 229 | + |
| 230 | +<div align="center"> |
| 231 | + |
| 232 | +```mermaid |
| 233 | +graph LR |
| 234 | + A[π΄ Fork] --> B[π¨ Code] |
| 235 | + B --> C[β
Test] |
| 236 | + C --> D[π€ PR] |
| 237 | + D --> E[π Merge] |
| 238 | + style A fill:#e3f2fd |
| 239 | + style B fill:#fff3e0 |
| 240 | + style C fill:#e8f5e9 |
| 241 | + style D fill:#fce4ec |
| 242 | + style E fill:#f3e5f5 |
| 243 | +``` |
| 244 | + |
| 245 | +</div> |
| 246 | + |
| 247 | +We welcome contributions! Please read our **[Contribution Guidelines](CONTRIBUTING.md)** before you contribute. |
| 248 | + |
| 249 | +<table> |
| 250 | +<tr> |
| 251 | +<td width="50%"> |
| 252 | + |
| 253 | +### π Quick Start |
| 254 | + |
| 255 | +```bash |
| 256 | +# 1. Fork & Clone |
| 257 | +git clone https://github.com/YOUR_USERNAME/Java.git |
| 258 | + |
| 259 | +# 2. Create Branch |
| 260 | +git checkout -b feature/your-algorithm |
| 261 | + |
| 262 | +# 3. Make Changes & Commit |
| 263 | +git commit -m "Add: Algorithm name" |
| 264 | + |
| 265 | +# 4. Push & Create PR |
| 266 | +git push origin feature/your-algorithm |
| 267 | +``` |
| 268 | + |
| 269 | +</td> |
| 270 | +<td width="50%"> |
| 271 | + |
| 272 | +### β
Requirements |
| 273 | + |
| 274 | +- **JavaDoc** - Document your code |
| 275 | +- **Tests** - Include JUnit tests |
| 276 | +- **Style** - Follow existing patterns |
| 277 | +- **Directory** - Update DIRECTORY.md |
| 278 | + |
| 279 | +<br> |
| 280 | + |
| 281 | +> β οΈ **Note:** We do **not** accept LeetCode problems. Focus on well-known algorithms. |
| 282 | +
|
| 283 | +</td> |
| 284 | +</tr> |
| 285 | +</table> |
| 286 | + |
| 287 | +--- |
| 288 | + |
| 289 | +## π Community & Support |
| 290 | + |
| 291 | +<div align="center"> |
| 292 | + |
| 293 | +<table> |
| 294 | +<tr> |
| 295 | +<td align="center" width="33%"> |
| 296 | +<img src="https://img.icons8.com/color/96/000000/discord-logo.png" width="50"/><br> |
| 297 | +<b>Discord</b><br> |
| 298 | +<a href="https://discord.gg/c7MnfGFGa6">Join discussions</a> |
| 299 | +</td> |
| 300 | +<td align="center" width="33%"> |
| 301 | +<img src="https://img.icons8.com/fluency/96/000000/bug.png" width="50"/><br> |
| 302 | +<b>Issues</b><br> |
| 303 | +<a href="https://github.com/TheAlgorithms/Java/issues">Report bugs</a> |
| 304 | +</td> |
| 305 | +<td align="center" width="33%"> |
| 306 | +<img src="https://img.icons8.com/fluency/96/000000/globe.png" width="50"/><br> |
| 307 | +<b>Website</b><br> |
| 308 | +<a href="https://the-algorithms.com">Explore more</a> |
| 309 | +</td> |
| 310 | +</tr> |
| 311 | +</table> |
| 312 | + |
| 313 | +</div> |
| 314 | + |
| 315 | +--- |
| 316 | + |
| 317 | +<div align="center"> |
| 318 | + |
| 319 | +## π License |
| 320 | + |
| 321 | +Licensed under the [MIT License](LICENSE). |
| 322 | + |
| 323 | +<br> |
| 324 | + |
| 325 | +``` |
| 326 | +ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| 327 | +β Made with β€οΈ by The Algorithms Community β |
| 328 | +β β Star this repository if you find it helpful! β |
| 329 | +ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| 330 | +``` |
12 | 331 |
|
13 | | -### All algorithms are implemented in Java (for educational purposes) |
14 | | -These implementations are intended for learning purposes. As such, they may be less efficient than the Java standard library. |
| 332 | +<br> |
15 | 333 |
|
16 | | -## Contribution Guidelines |
17 | | -Please read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute to this project. |
| 334 | +**[β¬ Back to Top](#-the-algorithms---java)** |
18 | 335 |
|
19 | | -## Algorithms |
20 | | -Our [directory](DIRECTORY.md) has the full list of applications. |
| 336 | +</div> |
0 commit comments