Skip to content

Conversation

ahyalfan
Copy link

@ahyalfan ahyalfan commented Sep 8, 2025

Description of Change

Problem

The original DelByPos function had incorrect position validation and boundary checks, causing errors when deleting nodes at valid positions, especially at the start and end of the list.
Specifically, the conditions used pos-1 inconsistently, leading to off-by-one errors and incorrect calls to deletion methods.

Solution

  • Updated position validation to correctly check if pos is within [1, ll.length].
  • Fixed boundary checks to correctly call DelAtEnd()whenpos == ll.length`.
  • Adjusted the switch cases accordingly to reflect 1-based indexing for positions.
  • Added test cases to cover successful deletions at various positions and to ensure invalid positions return false.

Testing

  • Added new tests for DelByPos() covering success and failure cases.
  • All tests pass.

Checklist

Notes:

Fixed off-by-one errors by properly validating position with 1-based
indexing.
Now DelByPos correctly handles deleting nodes at the beginning, middle,
and end.
Added checks for invalid positions to return false safely.
Copy link

github-actions bot commented Oct 9, 2025

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale label Oct 9, 2025
@ahyalfan
Copy link
Author

ahyalfan commented Oct 9, 2025

Still working on this, please keep it open.

@github-actions github-actions bot removed the stale label Oct 10, 2025
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.

1 participant