Skip to content

feat(searches): make verification repeatable for recursiveSearch (R45… - #45

Open
Sapna2007-sst wants to merge 1 commit into
S-AI-Projects:masterfrom
Sapna2007-sst:student/e26b07f0703/R05-T005
Open

Sapna2007-sst wants to merge 1 commit into
S-AI-Projects:masterfrom
Sapna2007-sst:student/e26b07f0703/R05-T005

Conversation

@Sapna2007-sst

Copy link
Copy Markdown

Description

This pull request ensures repeatable and deterministic verification for DepthFirstSearch.recursiveSearch, establishes input and state isolation tests, documents the zero-external-dependency contract, and adds a dependency injection seam preserving full backward compatibility.

Related Issue

Fixes: #5

Type of Change

  • Tests
  • Documentation
  • Bug Fix
  • New Feature
  • UI/UX Improvement
  • Performance Improvement
  • Refactoring / Maintenance
  • CI/CD

Changes Made

  • Added dependency injection seam DepthFirstSearch(List<T> visited) defaulting to new ArrayList<>() to preserve existing callers.
  • Added clearVisited() method for explicit accumulator reset between runs.
  • Documented state, repeatability, and zero-external-dependency contract in src/main/java/com/thealgorithms/searches/DepthFirstSearch.java.
  • Expanded src/test/java/com/thealgorithms/searches/DepthFirstSearchTest.java with tests covering:
    • Smallest valid input fixture (node = null returning Optional.empty()).
    • Ordinary input workflow fixture (target 4 in tree returning node 4 with visited [1, 2, 5, 6, 3, 4]).
    • Repeatability verification comparing two separate fresh isolated instances.
    • Sequential input isolation asserting prior searches do not alter subsequent search outcomes.
    • Dependency injection seam test recording visited nodes into an injected sink.
  • Added automated check runner work/R45-T005/check.py and saved verification evidence in work/R45-T005/results.json and work/R45-T005/evidence.md.

Screenshots / Recordings

N/A (tree search algorithm utility and unit tests; non-UI)

Testing

All changes have been validated locally using JDK 21 and Maven:

  • mvn test -Dtest=DepthFirstSearchTest (Tests run: 8, Failures: 0, Errors: 0, Skipped: 0)
  • mvn checkstyle:check (0 Checkstyle violations)
  • python3 work/R45-T005/check.py (All checks and repeatability assertions passed successfully)

Checklist

  • I have tested my changes locally.
  • I have added or updated tests, if needed.
  • I have updated documentation, if needed.
  • I have followed the project's coding guidelines.
  • I have run the relevant tests and checks.
  • I have addressed previous review feedback, if applicable.
  • 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 code adheres to repository style conventions and passes mvn checkstyle:check.

Additional Notes

  • Precondition lines establishing input requirements are explicitly cited in both the test methods and work/R45-T005/evidence.md.
  • Automated check runner can be verified anytime with python3 work/R45-T005/check.py.

…-T005)

- Add state and dependency contract documentation to DepthFirstSearch Javadoc
- Introduce dependency injection seam for visited list with default preserving backwards compatibility
- Add clearVisited method for accumulator reset
- Add regression tests verifying repeatability across isolated instances, sequential input isolation, smallest valid input (null node), ordinary input, and injected sink
- Add automated verification check runner work/R45-T005/check.py and verification evidence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant