Skip to content
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

Added Circular Linked List Data Structure #476

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

mohit-gogitter
Copy link
Contributor

@mohit-gogitter mohit-gogitter commented Oct 12, 2024

Circular Linked List

A Circular Linked List Data Structure is a variation of the linked list where the last node points back to the first node, forming a circular structure. In this implementation, I've created a circular linked list where each node contains data and a reference to the next node.

Here's a summary of key operations and their time complexities in this implementation:

  1. Insert at the Beginning: Adds a new node at the start of the list and links the new node to the existing nodes, ensuring the circular connection is maintained. (Time Complexity: O(1))
  2. Insert at the End: Adds a new node at the end of the list by finding the last node and updating its pointer to the new node, which is then linked back to the first node. (Time Complexity: O(n))
  3. Insert After a Given Node: Searches for a specific node in the list and inserts a new node after it while maintaining the circular connection. (Time Complexity: O(n))
  4. Delete a Node: Removes a node from the list by updating the pointers of the surrounding nodes. (Time Complexity: O(n))

Where It Can Be Used:

  • Operating Systems: In process scheduling where tasks are selected in a circular fashion.
  • Multimedia Applications: To manage looping playlists for audio and video playback.
  • Networking: In token-passing protocols for network communication.
  • Simulation or Game Development: For player turns in multiplayer games, simulating continuous cycles of events.

CheckList

  • I have performed a self-review of my code
  • My code follows the style guidelines of this project
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Comments in areas I changed are up to date
  • I have added comments to hard-to-understand areas of my code
  • I have made corresponding changes to the README.md

Copy link

codecov bot commented Oct 12, 2024

Codecov Report

Attention: Patch coverage is 98.82353% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.07%. Comparing base (36a7dd6) to head (9bd2413).

Files with missing lines Patch % Lines
...inkedList/CircularLinkedList/CircularLinkedList.cs 98.78% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #476      +/-   ##
==========================================
+ Coverage   95.00%   95.07%   +0.06%     
==========================================
  Files         246      248       +2     
  Lines       10367    10452      +85     
  Branches     1478     1490      +12     
==========================================
+ Hits         9849     9937      +88     
+ Misses        398      395       -3     
  Partials      120      120              

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

/// <summary>
/// Displays the contents of the Circular Linked List.
/// </summary>
public void Display()
Copy link
Member

Choose a reason for hiding this comment

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

Please remove display method and display-related logic from tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@mohit-gogitter
Copy link
Contributor Author

@siriak Can you please review

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.

2 participants