Skip to content

feat(datastructures): add SelfOrganizingLinkedList implementation and tests - #7575

Open
iamcodinghere22 wants to merge 9 commits into
TheAlgorithms:masterfrom
iamcodinghere22:feat/self-organizing-list
Open

feat(datastructures): add SelfOrganizingLinkedList implementation and tests#7575
iamcodinghere22 wants to merge 9 commits into
TheAlgorithms:masterfrom
iamcodinghere22:feat/self-organizing-list

Conversation

@iamcodinghere22

Copy link
Copy Markdown
Contributor

This PR implements the Self-Organizing Linked List data structure using the "Move To Front(MTF)" heuristic.
In this implementation, whenever an element is accessed/searched, it is dynamically moved to the head of the list. This optimizes access time for frequently requested items by keeping them near the front, achieving an {O(1)} best-case lookup time for repeated accesses.

Changes Included

  • Added SelfOrganizingLinkedList.java under com.thealgorithms.datastructures.lists.
  • Added comprehensive unit test coverage in SelfOrganizingLinkedListTest.java verifying search, insertion, edge cases (empty list, non-existent elements), and move-to-front behavior.

Testing

  • All unit tests in SelfOrganizingLinkedListTest.java pass locally (mvn test -Dtest=SelfOrganizingLinkedListTest).
  • Verified full build and test suite run successfully with JaCoCo code coverage.

Checklist

  • Code follows project coding guidelines.
  • Unit tests have been added for new functionality.
  • No duplicate code or classes introduced.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.74468% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.44%. Comparing base (31caee6) to head (259db0d).
⚠️ Report is 46 commits behind head on master.

Files with missing lines Patch % Lines
...datastructures/lists/SelfOrganizingLinkedList.java 94.28% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7575      +/-   ##
============================================
+ Coverage     79.89%   80.44%   +0.55%     
- Complexity     7348     7473     +125     
============================================
  Files           810      816       +6     
  Lines         23867    24092     +225     
  Branches       4703     4739      +36     
============================================
+ Hits          19069    19382     +313     
+ Misses         4036     3947      -89     
- Partials        762      763       +1     

☔ 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.

3 participants