Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: categoryx/JavaAlgorithms
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: TheAlgorithms/Java
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 16 commits
  • 23 files changed
  • 14 contributors

Commits on May 8, 2026

  1. Optimized NQueens implementation using hashing (TheAlgorithms#7416)

    * Optimized NQueens implementation using hashing
    
    * Fixed checkstyle naming issues
    
    * Fixed formatting issues
    
    * Fixed operator wrap formatting
    
    * Fixed formatting issues
    
    * Fixed operator wrapping style
    
    * Fixed print formatting
    
    * Fixed print formatting
    
    * Fixed operator formatting
    
    * Removed extra brace
    Bhanubasyan authored May 8, 2026
    Configuration menu
    Copy the full SHA
    54341c1 View commit details
    Browse the repository at this point in the history

Commits on May 9, 2026

  1. Configuration menu
    Copy the full SHA
    e814d97 View commit details
    Browse the repository at this point in the history

Commits on May 13, 2026

  1. feat: add Rat in a Maze backtracking algorithm (TheAlgorithms#7418)

    * feat: add Rat in a Maze backtracking algorithm with 10 unit tests
    
    * test: add coverage for all-open maze and larger maze path
    
    * style: apply clang-format fixes and add newline at end of files
    
    * style: apply clang-format and checkstyle fixes
    the-Sunny-Sharma authored May 13, 2026
    Configuration menu
    Copy the full SHA
    e7f8979 View commit details
    Browse the repository at this point in the history

Commits on May 15, 2026

  1. [ENHANCEMENT] Add Wavelet Tree Data Structure (TheAlgorithms#7414)

    * Implement Wavelet Tree with rank and kthSmallest methods
    
    * Implement Wavelet Tree with rank and kthSmallest methods
    
    * Fix checkstyle multiple variable declarations violation
    
    ---------
    
    Co-authored-by: Deniz Altunkapan <[email protected]>
    space0032 and DenizAltunkapan authored May 15, 2026
    Configuration menu
    Copy the full SHA
    0811cd0 View commit details
    Browse the repository at this point in the history

Commits on May 16, 2026

  1. Configuration menu
    Copy the full SHA
    783c96f View commit details
    Browse the repository at this point in the history

Commits on May 17, 2026

  1. Docs: add Javadoc to CoinChange class and method (TheAlgorithms#7424)

    * Fix: remove floating Javadoc comments causing compilation error
    
    * Docs: add Javadoc to CoinChange class and method
    
    * Style: apply clang-format to CoinChange.java
    BixbyCodes authored May 17, 2026
    Configuration menu
    Copy the full SHA
    8848ed1 View commit details
    Browse the repository at this point in the history

Commits on May 18, 2026

  1. fix: add null input validation to AlternativeStringArrange.arrange() (T…

    …heAlgorithms#7425)
    
    * fix: add null input validation to AlternativeStringArrange.arrange()
    
    The arrange() method previously threw a NullPointerException when either
    input string was null. This change explicitly validates the inputs and
    throws IllegalArgumentException with a clear message, matching the
    fail-fast pattern used by other utility classes in this package (e.g.
    HammingDistance).
    
    - Add null guard at the start of arrange()
    - Update Javadoc with @throws and contract notes
    - Add parameterized test covering all three null-input combinations
    
    * fix: remove unused JUnit @test import (Checkstyle violation)
    Shubh2-0 authored May 18, 2026
    Configuration menu
    Copy the full SHA
    4b8099c View commit details
    Browse the repository at this point in the history

Commits on May 21, 2026

  1. chore(deps): bump org.junit:junit-bom from 6.0.3 to 6.1.0 (TheAlgorit…

    …hms#7431)
    
    * chore(deps): bump org.junit:junit-bom from 6.0.3 to 6.1.0
    
    Bumps [org.junit:junit-bom](https://github.com/junit-team/junit-framework) from 6.0.3 to 6.1.0.
    - [Release notes](https://github.com/junit-team/junit-framework/releases)
    - [Commits](junit-team/junit-framework@r6.0.3...r6.1.0)
    
    ---
    updated-dependencies:
    - dependency-name: org.junit:junit-bom
      dependency-version: 6.1.0
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    
    * style: resolve `DLS_DEAD_LOCAL_STORE` in `testIteratorEmptyBag`
    
    ---------
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: vil02 <[email protected]>
    dependabot[bot] and vil02 authored May 21, 2026
    Configuration menu
    Copy the full SHA
    3ee310e View commit details
    Browse the repository at this point in the history
  2. feat: add optimized Digit DP template and unit tests (TheAlgorithms#7430

    )
    
    * feat: add optimized Digit DP template and unit tests
    
    * test: add test cases for max target sum and memoization hit to achieve 100% coverage
    
    * style: fix indentation and code formatting for clang linter compliance
    
    * fix: remove checkstyle inner assignment in solve method
    
    * fix: remove checkstyle inner assignment in solve method -newline at end
    premmsharma122 authored May 21, 2026
    Configuration menu
    Copy the full SHA
    0a62b11 View commit details
    Browse the repository at this point in the history

Commits on May 25, 2026

  1. feat(datastructures): add thread-safe bounded queue implementation (T…

    …heAlgorithms#7428)
    
    * feat(datastructures): add thread-safe bounded queue implementation
    
    Implements a thread-safe blocking queue using ReentrantLock and
    Condition variables for producer-consumer synchronization.
    
    ### What This Adds
    
    **ThreadSafeQueue.java** - Thread-safe bounded queue:
    - `enqueue()` - Blocking add to tail, waits when queue is full
    - `dequeue()` - Blocking remove from head, waits when queue is empty
    - `offer()` - Non-blocking add, returns false when full
    - `poll()` - Non-blocking remove, returns null when empty
    - `size()`, `isEmpty()`, `isFull()`, `capacity()` - State queries
    - Uses circular buffer for O(1) enqueue/dequeue operations
    - Supports multiple concurrent producers and consumers
    
    **ThreadSafeQueueTest.java** - Comprehensive test suite:
    - Basic enqueue/dequeue operations
    - Offer/poll non-blocking behavior
    - Null rejection validation
    - Invalid capacity rejection
    - Circular buffer wrap-around
    - Multiple producers single consumer concurrency
    - Single producer multiple consumers concurrency
    - Blocking behavior verification
    - Stress test with 8 concurrent threads
    
    ### Algorithm
    
    Uses a circular buffer with ReentrantLock and two Condition variables:
    - `notFull` - signaled when space becomes available
    - `notEmpty` - signaled when items are added
    - Producers await notFull when buffer is full
    - Consumers await notEmpty when buffer is empty
    - Signal opposite condition after each operation
    
    Time: O(1) enqueue/dequeue | Space: O(n) bounded buffer
    
    ### Reference
    
    https://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem
    
    * fix(datastructures): correct test capacity and simplify concurrent test
    
    - testOfferPoll: Changed capacity from 3 to 2 so third offer correctly fails
    - testMultipleProducersSingleConsumer: Removed startLatch, use dedicated
      consumer thread with synchronized results list for thread safety
    
    * fix(datastructures): remove unused assertArrayEquals import
    
    Checkstyle flagged UnusedImports violation for
    org.junit.jupiter.api.Assertions.assertArrayEquals which was
    not used in any test method.
    
    * fix: replace signal() with signalAll() to satisfy SpotBugs MDM_SIGNAL_NOT_SIGNALALL
    
    SpotBugs flags all four Condition.signal() calls in ThreadSafeQueue as Medium
    severity bugs (MDM_SIGNAL_NOT_SIGNALALL). In a multi-producer/multi-consumer
    scenario, signal() wakes only one waiting thread, which can cause deadlock when
    multiple producers or consumers are blocked on the same condition variable.
    Using signalAll() ensures all waiting threads are notified and can re-check
    their loop condition, preventing the lost-wakeup problem that occurs when a
    single signal wakes a thread that cannot make progress.
    
    This change affects enqueue(), dequeue(), offer(), and poll() methods where
    notEmpty.signal() and notFull.signal() are replaced with notEmpty.signalAll()
    and notFull.signalAll() respectively.
    
    * test: replace static imports with Assertions prefix to satisfy PMD TooManyStaticImports
    
    PMD flags TooManyStaticImports when more than 4 static imports are present.
    The test file had 5 static imports from org.junit.jupiter.api.Assertions
    (equals, assertFalse, assertNull, assertThrows, assertTrue) which exceeded
    the default threshold. Replaced with regular import and Assertions.
    prefix to eliminate the PMD violation while maintaining readability.
    MD-Mushfiqur123 authored May 25, 2026
    Configuration menu
    Copy the full SHA
    e49cd55 View commit details
    Browse the repository at this point in the history

Commits on May 26, 2026

  1. Configuration menu
    Copy the full SHA
    42007c8 View commit details
    Browse the repository at this point in the history

Commits on May 27, 2026

  1. chore(deps-dev): bump org.apache.maven.plugins:maven-surefire-plugin …

    …from 3.5.5 to 3.5.6 (TheAlgorithms#7436)
    
    chore(deps-dev): bump org.apache.maven.plugins:maven-surefire-plugin
    
    Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.5.5 to 3.5.6.
    - [Release notes](https://github.com/apache/maven-surefire/releases)
    - [Commits](apache/maven-surefire@surefire-3.5.5...surefire-3.5.6)
    
    ---
    updated-dependencies:
    - dependency-name: org.apache.maven.plugins:maven-surefire-plugin
      dependency-version: 3.5.6
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored May 27, 2026
    Configuration menu
    Copy the full SHA
    0905cbe View commit details
    Browse the repository at this point in the history

Commits on May 28, 2026

  1. Configuration menu
    Copy the full SHA
    7b1995f View commit details
    Browse the repository at this point in the history

Commits on May 31, 2026

  1. chore(deps): bump com.puppycrawl.tools:checkstyle from 13.4.2 to 13.5…

    ….0 (TheAlgorithms#7441)
    
    Bumps [com.puppycrawl.tools:checkstyle](https://github.com/checkstyle/checkstyle) from 13.4.2 to 13.5.0.
    - [Release notes](https://github.com/checkstyle/checkstyle/releases)
    - [Commits](checkstyle/checkstyle@checkstyle-13.4.2...checkstyle-13.5.0)
    
    ---
    updated-dependencies:
    - dependency-name: com.puppycrawl.tools:checkstyle
      dependency-version: 13.5.0
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored May 31, 2026
    Configuration menu
    Copy the full SHA
    978a306 View commit details
    Browse the repository at this point in the history

Commits on Jun 3, 2026

  1. test: refactor MergeSortedArrayListTest using JUnit 5 parameterized t…

    …ests (TheAlgorithms#7445)
    
    * test: upgrade MergeSortedArrayListTest to use JUnit 5 parameterized tests
    
    * style: strip trailing whitespace and add trailing newline via IDE
    
    * style: align layout with clang-format rules
    
    * style: collapse stream arguments to single lines for clang
    
    * style: fix line wrapping length for clang linter
    
    ---------
    
    Co-authored-by: psawale <[email protected]>
    sawaleparas and parassawale authored Jun 3, 2026
    Configuration menu
    Copy the full SHA
    5feaba6 View commit details
    Browse the repository at this point in the history
  2. feat(matrix): add QR decomposition algorithm using Gram-Schmidt proce…

    …ss (TheAlgorithms#7427)
    
    * feat(matrix): add QR decomposition algorithm using Gram-Schmidt process
    
    Decomposes a matrix A into an orthogonal matrix Q and an upper triangular
    matrix R such that A = Q * R.
    
    ### What This Adds
    
    **QRDecomposition.java** - Main algorithm implementation:
    - `decompose()` - Performs QR factorization using the Gram-Schmidt process
    - Returns a QR object containing both Q (orthogonal) and R (upper triangular) matrices
    - Validates input matrix using MatrixUtil.validateInputMatrix()
    - Throws ArithmeticException for rank-deficient matrices
    
    **QRDecompositionTest.java** - Unit tests:
    - Tests for 2x2 and 3x3 matrix decomposition
    - Verifies Q * R reconstruction equals original matrix
    - Validates Q columns are orthonormal
    - Confirms R is upper triangular
    - Tests identity matrix decomposition
    - Tests rank-deficient matrix rejection
    - Tests null and empty matrix rejection
    
    ### Algorithm
    
    The Gram-Schmidt process orthogonalizes columns iteratively:
    - For each column j, subtract projections onto previous orthogonal vectors
    - Normalize to get j-th column of Q
    - Store coefficients in R[i][j]
    
    Time: O(m*n^2) | Space: O(m*n + n^2)
    
    ### Reference
    
    https://en.wikipedia.org/wiki/QR_decomposition
    
    * fix(matrix): inline matrix validation to avoid cross-package dependency
    
    MatrixUtil is in com.thealgorithms.matrix.utils package which causes
    compilation errors when referenced from com.thealgorithms.matrix.
    Inlined the validation logic (validateInputMatrix, hasValidRows,
    isJaggedMatrix) directly into QRDecomposition to resolve the issue.
    MD-Mushfiqur123 authored Jun 3, 2026
    Configuration menu
    Copy the full SHA
    cecfad9 View commit details
    Browse the repository at this point in the history
Loading