Skip to content

Latest commit

 

History

History
336 lines (247 loc) · 7.98 KB

File metadata and controls

336 lines (247 loc) · 7.98 KB

🔷 The Algorithms - Java

Java Logo

All algorithms implemented in Java (for educational purposes)

Build codecov Discord chat Gitpod ready-to-code

Open in Gitpod


📚 Explore Algorithms🤝 Contributing💬 Community


┌─────────────────────────────────────────────────────────────────┐
│                                                                 │
│  📖  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.

🎁 What's Inside?
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

🚀 Getting Started

📋 Prerequisites

☕ Java 21+
📦 Maven 3.6+

⚡ Quick Setup

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

💡 Usage Examples

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

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

📊 Dynamic Programming

import com.thealgorithms.dynamicprogramming.Fibonacci;

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

🔀 Sorting

import com.thealgorithms.sorts.QuickSort;

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

🌐 Graph Algorithms

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

import com.thealgorithms.datastructures.stacks.BalancedBrackets;

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

📚 Algorithm Categories

╔═══════════════════════════════════════════════════════════════╗
║                    ALGORITHM CATEGORIES                       ║
╚═══════════════════════════════════════════════════════════════╝

🔍 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

🎯 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

🤝 Contributing

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
Loading

We welcome contributions! Please read our Contribution Guidelines before you contribute.

🚀 Quick Start

# 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

✅ Requirements

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

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


🌐 Community & Support


Discord
Join discussions

Issues
Report bugs

Website
Explore more

📄 License

Licensed under the MIT License.


╔════════════════════════════════════════════════════════╗
║  Made with ❤️ by The Algorithms Community              ║
║  ⭐ Star this repository if you find it helpful!       ║
╚════════════════════════════════════════════════════════╝

⬆ Back to Top