Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
334 changes: 325 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,336 @@
# The Algorithms - Java
<div align="center">

# πŸ”· The Algorithms - Java

<img src="https://upload.wikimedia.org/wikipedia/en/3/30/Java_programming_language_logo.svg" alt="Java Logo" width="200"/>

### All algorithms implemented in Java (for educational purposes)

[![Build](https://github.com/TheAlgorithms/Java/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/TheAlgorithms/Java/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/TheAlgorithms/Java/graph/badge.svg?token=XAdPyqTIqR)](https://codecov.io/gh/TheAlgorithms/Java)
[![Discord chat](https://img.shields.io/discord/808045925556682782.svg?logo=discord&colorB=7289DA&style=flat-square)](https://discord.gg/c7MnfGFGa6)
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/TheAlgorithms/Java)

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/TheAlgorithms/Java)

You can run and edit the algorithms, or contribute to them using Gitpod.io (a free online development environment) with a single click.
---

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/TheAlgorithms/Java)
**[πŸ“š Explore Algorithms](DIRECTORY.md)** β€’ **[🀝 Contributing](CONTRIBUTING.md)** β€’ **[πŸ’¬ Community](https://discord.gg/c7MnfGFGa6)**

</div>

<br>

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚
β”‚ πŸ“– Educational implementations of algorithms in Java β”‚
β”‚ 🎯 Focus on code clarity and learning β”‚
β”‚ πŸ§ͺ Comprehensive test coverage β”‚
β”‚ πŸ“ Well-documented with JavaDoc β”‚
β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## πŸ“– Overview

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.

<details>
<summary><b>🎁 What's Inside?</b></summary>

<br>

| Feature | Description |
|---------|-------------|
| πŸ“ **Clean Code** | Readable implementations with clear variable names |
| πŸ§ͺ **Test Coverage** | JUnit test coverage for most algorithms |
| πŸ“š **Documentation** | JavaDoc comments with time/space complexity |
| β˜• **Modern Java** | Leverages Java 21 features |
| πŸ—‚οΈ **Organized** | Algorithms grouped by category |

</details>

---

## πŸš€ Getting Started

<table>
<tr>
<td width="50%">

### πŸ“‹ Prerequisites

```bash
β˜• Java 21+
πŸ“¦ Maven 3.6+
```

</td>
<td width="50%">

### ⚑ Quick Setup

```bash
git clone https://github.com/TheAlgorithms/Java.git
cd Java
mvn clean compile
mvn test
```

</td>
</tr>
</table>

---

## πŸ’‘ Usage Examples

<div align="center">

```mermaid
graph LR
A[Import Algorithm] --> B[Call Method]
B --> C[Get Result]
style A fill:#e1f5ff
style B fill:#fff3e0
style C fill:#e8f5e9
```

</div>

All algorithms are implemented as static methods. Import and use them directly:

<table>
<tr>
<td width="50%">

**πŸ“Š Dynamic Programming**
```java
import com.thealgorithms.dynamicprogramming.Fibonacci;

int fib = Fibonacci.fibonacci(10); // 55
```

**πŸ”€ Sorting**
```java
import com.thealgorithms.sorts.QuickSort;

int[] array = {64, 34, 25, 12, 22, 11, 90};
QuickSort.quickSort(array, 0, array.length - 1);
```

</td>
<td width="50%">

**🌐 Graph Algorithms**
```java
import com.thealgorithms.datastructures.graphs.DijkstraAlgorithm;

int[][] graph = {{0, 4, 0}, {4, 0, 8}, {0, 8, 0}};
DijkstraAlgorithm dijkstra = new DijkstraAlgorithm(3);
int[] distances = dijkstra.run(graph, 0);
```

**πŸ“¦ Data Structures**
```java
import com.thealgorithms.datastructures.stacks.BalancedBrackets;

boolean isBalanced = BalancedBrackets.isBalanced("{[()]}");
```

</td>
</tr>
</table>

---

## πŸ“š Algorithm Categories

<div align="center">

```
╔═══════════════════════════════════════════════════════════════╗
β•‘ ALGORITHM CATEGORIES β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
```

</div>

<table>
<tr>
<td width="50%" valign="top">

### πŸ” Sorting & Searching
```
β”œβ”€β”€ Binary Search
β”œβ”€β”€ Linear Search
β”œβ”€β”€ Jump Search
β”œβ”€β”€ Quick Sort
β”œβ”€β”€ Merge Sort
β”œβ”€β”€ Heap Sort
└── Radix Sort
```

### 🌳 Data Structures
```
β”œβ”€β”€ Trees
β”‚ β”œβ”€β”€ BST
β”‚ β”œβ”€β”€ AVL
β”‚ └── Red-Black
β”œβ”€β”€ Graphs
β”‚ β”œβ”€β”€ DFS / BFS
β”‚ β”œβ”€β”€ Dijkstra
β”‚ └── Bellman-Ford
└── Collections
β”œβ”€β”€ Stacks
β”œβ”€β”€ Queues
└── Heaps
```

</td>
<td width="50%" valign="top">

### 🎯 Algorithm Techniques
```
β”œβ”€β”€ Dynamic Programming
β”‚ β”œβ”€β”€ Knapsack
β”‚ β”œβ”€β”€ LCS
β”‚ └── Edit Distance
β”œβ”€β”€ Greedy Algorithms
β”œβ”€β”€ Backtracking
β”‚ β”œβ”€β”€ N-Queens
β”‚ └── Sudoku Solver
└── Divide & Conquer
```

### πŸ” Other Topics
```
β”œβ”€β”€ Cryptography & Ciphers
β”œβ”€β”€ Mathematical Algorithms
β”œβ”€β”€ String Manipulation
β”œβ”€β”€ Bit Operations
└── Audio Processing
```

</td>
</tr>
</table>

<div align="center">

πŸ“‹ **[View Complete Directory β†’](DIRECTORY.md)**

</div>

---

## 🀝 Contributing

<div align="center">

```mermaid
graph LR
A[🍴 Fork] --> B[πŸ”¨ Code]
B --> C[βœ… Test]
C --> D[πŸ“€ PR]
D --> E[πŸŽ‰ Merge]
style A fill:#e3f2fd
style B fill:#fff3e0
style C fill:#e8f5e9
style D fill:#fce4ec
style E fill:#f3e5f5
```

</div>

We welcome contributions! Please read our **[Contribution Guidelines](CONTRIBUTING.md)** before you contribute.

<table>
<tr>
<td width="50%">

### πŸš€ Quick Start

```bash
# 1. Fork & Clone
git clone https://github.com/YOUR_USERNAME/Java.git

# 2. Create Branch
git checkout -b feature/your-algorithm

# 3. Make Changes & Commit
git commit -m "Add: Algorithm name"

# 4. Push & Create PR
git push origin feature/your-algorithm
```

</td>
<td width="50%">

### βœ… Requirements

- **JavaDoc** - Document your code
- **Tests** - Include JUnit tests
- **Style** - Follow existing patterns
- **Directory** - Update DIRECTORY.md

<br>

> ⚠️ **Note:** We do **not** accept LeetCode problems. Focus on well-known algorithms.

</td>
</tr>
</table>

---

## 🌐 Community & Support

<div align="center">

<table>
<tr>
<td align="center" width="33%">
<img src="https://img.icons8.com/color/96/000000/discord-logo.png" width="50"/><br>
<b>Discord</b><br>
<a href="https://discord.gg/c7MnfGFGa6">Join discussions</a>
</td>
<td align="center" width="33%">
<img src="https://img.icons8.com/fluency/96/000000/bug.png" width="50"/><br>
<b>Issues</b><br>
<a href="https://github.com/TheAlgorithms/Java/issues">Report bugs</a>
</td>
<td align="center" width="33%">
<img src="https://img.icons8.com/fluency/96/000000/globe.png" width="50"/><br>
<b>Website</b><br>
<a href="https://the-algorithms.com">Explore more</a>
</td>
</tr>
</table>

</div>

---

<div align="center">

## πŸ“„ License

Licensed under the [MIT License](LICENSE).

<br>

```
╔════════════════════════════════════════════════════════╗
β•‘ Made with ❀️ by The Algorithms Community β•‘
β•‘ ⭐ Star this repository if you find it helpful! β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
```

### All algorithms are implemented in Java (for educational purposes)
These implementations are intended for learning purposes. As such, they may be less efficient than the Java standard library.
<br>

## Contribution Guidelines
Please read our [Contribution Guidelines](CONTRIBUTING.md) before you contribute to this project.
**[⬆ Back to Top](#-the-algorithms---java)**

## Algorithms
Our [directory](DIRECTORY.md) has the full list of applications.
</div>
Loading