The Algorithms - Java

repository·master·Indexed 13 days ago

https://github.com/thealgorithms/java

An educational repository containing various algorithm and data structure implementations in Java. It includes comprehensive examples of graphs (BFS, DFS, Dijkstra's, Bellman-Ford), HashMaps, Heaps, and Linked Lists, designed for learning purposes rather than high-performance production use.

Tokens
17.2K
Snippets
48
Records
106
Agent score
94%

What's inside The Algorithms - Java

  1. Explore stack-based algorithms

    master
    The com.thealgorithms.stacks package provides algorithms that utilize stack data structures. This includes expression evaluation (InfixToPostfix, PostfixEvaluator), bracket validation (BalancedBrackets, ValidParentheses), and specialized stack problems like TrappingRainwater or CelebrityFinder.
  2. Explore the project structure and algorithm categories

    master

    The repository is organized into several specialized directories under src/main/java/com/thealgorithms/, each containing specific algorithm implementations. You can find implementations for the following categories:

    • maths: Basic mathematical operations, series, and number properties.
    • prime: Primality testing, factorization, and number theory functions.
    • matrix: Linear algebra operations including multiplication, inversion, and decomposition.
    • misc: Miscellaneous algorithms like MapReduce, shuffling, and array problems.
    • others: A wide variety of algorithms including CRC, Huffman coding, and sorting.
    • physics: Physical simulations and formulas (e.g., Kinematics, Gravitation).
    • puzzlesandgames: Logic puzzles like Tower of Hanoi.
    • randomized: Algorithms that use randomness (e.g., Monte Carlo, Reservoir Sampling).
    • recursion: Demonstrations of recursive patterns.
    • scheduling: Operating system and task scheduling algorithms (e.g., FCFS, SJF, Priority Scheduling).
  3. Explore sorting algorithms

    master
    The com.thealgorithms.sorts package contains various implementations of sorting algorithms. You can find specific implementations such as MergeSort, QuickSort, RadixSort, and TimSort. For utility functions related to sorting, refer to SortUtils and SortUtilsRandomGenerator.
  4. Explore string manipulation algorithms

    master
    The com.thealgorithms.strings package contains a wide array of string-related algorithms, including pattern matching (KMP, RabinKarp, AhoCorasick), palindrome checks, and string transformations. Some specialized patterns, like ZigZagPattern, are located in sub-packages.
  5. Explore Other algorithms

    master

    The com.thealgorithms.others package contains a collection of diverse algorithms that do not fit into specific mathematical or matrix categories. Examples include:

    • Graph & Search: Dijkstra (shortest path) and IterativeFloodFill.
    • String & Pattern Matching: BoyerMoore and Huffman (compression).
    • Data Structures: Implementing_auto_completing_features_using_trie.
    • Game Theory & Simulation: MiniMaxAlgorithm and Conway (Game of Life).
    • Checksums & Security: CRC16, CRC32, and Luhn algorithm.
  6. Explore Matrix algorithms

    master

    The com.thealgorithms.matrix package provides tools for linear algebra and matrix manipulation. Key features include:

    • Core Operations: MatrixMultiplication, MatrixTranspose, InverseOfMatrix, and MatrixRank.
    • Matrix Transformations: RotateMatrixBy90Degrees, MirrorOfMatrix, and PrintAMatrixInSpiralOrder.
    • Systems & Decomposition: LUDecomposition and SolveSystem.
    • Specialized Matrices: StochasticMatrix and Fibonacci (via matrixexponentiation).
    • Utilities: MatrixUtil for common helper operations.
  7. Explore Mathematics algorithms

    master

    The com.thealgorithms.maths package contains a wide variety of mathematical implementations. Key sub-categories include:

    • Prime Number Algorithms: Located in com.thealgorithms.maths.Prime, including primality tests like MillerRabinPrimalityCheck, SolovayStrassenPrimalityTest, and sieves like SieveOfEratosthenes and SieveOfAtkin.
    • Number Theory & Series: Implementations for LucasSeries, PascalTriangle, PythagoreanTriple, and various number properties (e.g., PerfectNumber, SmithNumber, VampireNumber).
    • Calculus & Approximation: Tools like SimpsonIntegration, PiApproximation, and square root methods (SquareRootWithBabylonianMethod, SquareRootWithNewtonRaphsonMethod).
    • Statistics: Basic statistical measures such as Means, Median, Mode, StandardDeviation, and StandardScore.
  8. Explore Miscellaneous algorithms

    master

    The com.thealgorithms.misc package contains general-purpose algorithmic implementations, such as:

    • Array & List Utilities: ShuffleArray, RangeInSortedArray, and PalindromeSinglyLinkedList.
    • Running Medians: Specialized implementations for different data types like MedianOfRunningArrayInteger, MedianOfRunningArrayDouble, etc.
    • Problem Solving: Implementations for classic problems like TwoSumProblem, ThreeSumProblem, and MapReduce.
  9. Identify different types of tree data structures

    master

    The repository provides implementations for several tree variations:

    • Binary Search Tree (BST): Elements are inserted in sorted order. Searching typically takes $O(\log N)$ time, depending on the tree structure.
    • AVL Tree and Red-Black Tree: Balanced binary search trees that guarantee $O(\log N)$ searching time by maintaining tree height.
    • MultiWay Search Tree: A tree where internal nodes can have more than two children.
    • Trie: A character-based multiway search tree used for prefix-based retrieval and search algorithms.
  10. Explore the project structure of The Algorithms - Java

    master

    The project is organized by algorithm categories within the src/main/java/com/thealgorithms/ directory. Each category contains specific implementations and corresponding test files located in src/test/java/com/thealgorithms/.

    Key algorithm categories available in the repository include:

    • diskscheduling: Disk scheduling algorithms (e.g., SCAN, LOOK, SSTF).
    • searches: Searching algorithms (e.g., Binary Search, Boyer-Moore, Rabin-Karp).
    • slidingwindow: Algorithms utilizing the sliding window technique.
    • sorts: Various sorting algorithms (e.g., QuickSort, MergeSort, TimSort).
    • stacks: Stack-based algorithms and data structures (e.g., Infix to Postfix conversion, MinStack).
    • scheduling: Scheduling algorithms.