Skip to content

To Fix maze recursion boundary validation with code improvements - #7672

Open
NithinU2802 wants to merge 20 commits into
TheAlgorithms:masterfrom
NithinU2802:fix/maze-recursion-boundary-validation
Open

NithinU2802 wants to merge 20 commits into
TheAlgorithms:masterfrom
NithinU2802:fix/maze-recursion-boundary-validation

Conversation

@NithinU2802

@NithinU2802 NithinU2802 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

This PR solves,

  • Fixed the maze solver so it checks maze boundaries instead of trying to access cells outside the maze. The existing methods keep their current start and destination, and now return null if those positions don't fit the maze.
  • Added overloads that let callers provide start and destination coordinates, along with checks for invalid coordinates and malformed mazes.
  • Added tests for small mazes, both search strategies, invalid coordinates, and mazes with no path.
  • Did code improvement to avoid duplication.

Closes #7671

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new algorithms include a corresponding test class that validates their functionality.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter

codecov-commenter commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.27%. Comparing base (a7a2441) to head (c85fdb2).

Files with missing lines Patch % Lines
.../com/thealgorithms/backtracking/MazeRecursion.java 97.22% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7672      +/-   ##
============================================
+ Coverage     82.21%   82.27%   +0.05%     
- Complexity     8401     8431      +30     
============================================
  Files           843      843              
  Lines         26141    26145       +4     
  Branches       5100     5104       +4     
============================================
+ Hits          21493    21510      +17     
+ Misses         3854     3843      -11     
+ Partials        794      792       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] MazeRecursion crashes on small mazes

2 participants