Skip to content

[R45-T012] Define and test supported boundaries of TortoiseHareAlgo.Node - #54

Open
shyamlibakale1001-alt wants to merge 1 commit into
S-AI-Projects:masterfrom
shyamlibakale1001-alt:student/e26b07f0813/R45-T012
Open

shyamlibakale1001-alt wants to merge 1 commit into
S-AI-Projects:masterfrom
shyamlibakale1001-alt:student/e26b07f0813/R45-T012

Conversation

@shyamlibakale1001-alt

Copy link
Copy Markdown

Description

Documents the supported boundaries of TortoiseHareAlgo.Node and TortoiseHareAlgo in src/main/java/com/thealgorithms/datastructures/lists/TortoiseHareAlgo.java, adds focused boundary regression tests (TortoiseHareAlgoBoundaryTest.java), and adds a focused runner (work/R45-T012/check.py) that executes the checks and records inputs, expected versus actual results, and tool versions. All existing behavior and public interfaces are preserved.

Related Issue

Fixes: #12

Type of Change

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

Changes Made

  • Documented the supported boundary contract on TortoiseHareAlgo (lines 3–20) and Node (lines 22–26) in src/main/java/com/thealgorithms/datastructures/lists/TortoiseHareAlgo.java: empty list sentinel (null / "[]"), smallest non-empty 1-node list, even-length second-middle selection, nullable element values, and private Node constructor preserving acyclic lists. No executable code or public API was modified.
  • Added src/test/java/com/thealgorithms/datastructures/lists/TortoiseHareAlgoBoundaryTest.java with 5 test methods (18 logged boundary checks):
    • Smallest valid Node ([7]) and empty-list sentinel ([] → null / "[]").
    • Ordinary interior list ([10, 20, 30, 40, 50]) and step-by-step growth across lengths 1..5.
    • Explicit boundary table asserting each side of the documented boundaries (0, 1, 2, 3, 4, 5 nodes).
    • Nullable Node value boundary ([null] → null / "[null]", and [a, null, c]).
    • Encapsulation boundary verifying Node is final and Node(E, Node<E>) is private.
  • Added work/R45-T012/check.py (with evidence files in work/R45-T012/), running mvn test for TortoiseHareAlgoBoundaryTest, enforcing a nonzero test count, saving comparisons.txt, result.txt, mvn_output.txt, and tool_versions.txt, and exiting non-zero on failure.

Screenshots / Recordings

Not applicable (no UI changes).

Testing

Command: python3 work/R45-T012/check.py
(runs mvn -B test -Dtest=TortoiseHareAlgoBoundaryTest -Dsurefire.failIfNoSpecifiedTests=false)

Result: tests=5 failures/errors=0 skipped=0 boundaries=18 mvn_exit=0, status=PASS

Existing suite: mvn -B test -Dtest=TortoiseHareAlgoTest -Dsurefire.failIfNoSpecifiedTests=false → Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 (BUILD SUCCESS).

Negative check: temporarily forcing the fast/slow loop condition on line 64 to skip (while (fast != null && fast.next != null && slow == null)) caused python3 work/R45-T012/check.py to print status=FAIL (tests=5 failures/errors=3 skipped=0 mvn_exit=1) and exit non-zero; reverted and re-verified.

Style: mvn -B checkstyle:check reports 0 Checkstyle violations (BUILD SUCCESS).

Tool versions and boundary outputs are saved in work/R45-T012/tool_versions.txt and work/R45-T012/comparisons.txt.

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.

Additional Notes

  • No guard changes were required because TortoiseHareAlgo already handles empty (head == null), single-node, even/odd, and null-element lists cleanly while encapsulating Node(E, Node<E>) as private.

  • The work/R45-T012/ evidence folder is for coursework review only and should not go into any later upstream PR.

  • 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

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