Skip to content

Add cycle creation utility and detection tests for Linked List (Fixes #583) #2052

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sowmya-rebbavarapu
Copy link

Description:
This pull request adds the ability to create a cycle in the linked list by linking the tail node to any node at a specified position. It includes:

A utility function createCycle(list, position) that links the last node to the node at the given position to form a cycle.

Unit tests to verify cycle creation and detection using the existing detectCycle function.

Tests cover normal cases, invalid positions, and no-cycle scenarios.

This addresses the feature request in issue #583 opened by @chrisVillanueva, enabling users to create and detect cycles within linked lists for more comprehensive linked list operations.

Please review the implementation and tests. Looking forward to your feedback!

@lazarljubenovic
Copy link

That's not a linked list anymore.

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