TheAlgorithms / C-Sharp

All algorithms implemented in C#.
GNU General Public License v3.0
7.17k stars 1.53k forks source link

Added Circular Linked List Data Structure #476

Closed mohit-gogitter closed 1 month ago

mohit-gogitter commented 1 month ago

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:

CheckList

codecov[bot] commented 1 month ago

Codecov Report

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

Project coverage is 95.13%. Comparing base (93febae) to head (7580b7a). Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...inkedList/CircularLinkedList/CircularLinkedList.cs 98.78% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #476 +/- ## ========================================== + Coverage 95.07% 95.13% +0.06% ========================================== Files 259 261 +2 Lines 10710 10795 +85 Branches 1504 1516 +12 ========================================== + Hits 10182 10270 +88 + Misses 403 400 -3 Partials 125 125 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

mohit-gogitter commented 1 month ago

@siriak Can you please review

mohit-gogitter commented 1 month ago

@siriak Can you please review and merge as the PR is opened since 2 weeks