Skip to content

Create Unrolled Linked List #5835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

vishantrathi
Copy link

A linked list variant that stores multiple elements in each node to improve cache performance.

  • 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 code is formatted with clang-format -i --style=file path/to/your/file.java

A linked list variant that stores multiple elements in each node to improve cache performance.
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.00%. Comparing base (30504c1) to head (1432187).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5835      +/-   ##
============================================
+ Coverage     65.99%   66.00%   +0.01%     
  Complexity     4395     4395              
============================================
  Files           603      603              
  Lines         16799    16799              
  Branches       3226     3226              
============================================
+ Hits          11086    11088       +2     
+ Misses         5266     5265       -1     
+ Partials        447      446       -1     

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

private Node head;
private int nodeCapacity; // Maximum capacity of each node

// Constructor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant comment. Will be better to remove it.

@@ -0,0 +1,52 @@
class UnrolledLinkedList {
private Node head;
private int nodeCapacity; // Maximum capacity of each node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be better move it to javadoc

nodeCapacity = capacity;
}

// Insert an element at the end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also, will be better to have like javadoc

// Constructor
public UnrolledLinkedList(int capacity) {
head = null;
nodeCapacity = capacity;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add checking for wrong input.

public UnrolledLinkedList(int capacity) {
    if (capacity <= 0) {
        throw new IllegalArgumentException("Node capacity must be positive");
    }
    this.head = null;
    this.nodeCapacity = capacity;
}

}

// Display the unrolled linked list
public void display() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant method because usually standard interface for List data structure not include it. You can discover standard java List interface.

@@ -0,0 +1,52 @@
class UnrolledLinkedList {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also very useful to have multiple Junit tests.

Copy link

github-actions bot commented Dec 6, 2024

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution!

@github-actions github-actions bot added the stale label Dec 6, 2024
Copy link

Please reopen this pull request once you have made the required changes. If you need help, feel free to ask in our Discord server or ping one of the maintainers here. Thank you for your contribution!

@github-actions github-actions bot closed this Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants