Skip to content

Add is_palindrome method to LinkedList class#657

Open
asmit27rai wants to merge 1 commit into
codezonediitj:mainfrom
asmit27rai:palidr_ll
Open

Add is_palindrome method to LinkedList class#657
asmit27rai wants to merge 1 commit into
codezonediitj:mainfrom
asmit27rai:palidr_ll

Conversation

@asmit27rai

Copy link
Copy Markdown

What's this PR about?

This PR adds a new method is_palindrome to the LinkedList class to check if a linked list is a palindrome. The method works for all types of linked lists: SinglyLinkedList, DoublyLinkedList, SinglyCircularLinkedList, and DoublyCircularLinkedList.

What changes were made?

  1. New Method:

    • Added is_palindrome to the LinkedList class.
    • The method traverses the linked list, stores elements in a temporary array, and checks if the array is equal to its reverse.
  2. Tests:

    • Added comprehensive test cases for is_palindrome in the test file.
    • Verified functionality for all linked list types.

Fixes: #656

- Implemented `is_palindrome` method to check if a linked list is a palindrome.
- The method works for all types of linked lists: SinglyLinkedList, DoublyLinkedList, SinglyCircularLinkedList, and DoublyCircularLinkedList.
- Added comprehensive test cases to verify the functionality.

@czgdp1807 czgdp1807 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is_palindrone is applicable to any linear data structure right? So let's add it in linear_data_structures/algorithms.py. Keep the method here and call it in is_palindrone in algorithms.py file. Also implement is_palindrone method in OneDimensionalArray, DynamicOneDimensionalArray.

@asmit27rai

Copy link
Copy Markdown
Author

is_palindrone is applicable to any linear data structure right? So let's add it in linear_data_structures/algorithms.py. Keep the method here and call it in is_palindrone in algorithms.py file. Also implement is_palindrone method in OneDimensionalArray, DynamicOneDimensionalArray.

@czgdp1807 So do you want to keep the method here and also add is_palidrome method in OneDimensionalArray and DynamicOneDimensionalArray. And call them in algorithms.py ?

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.

Palindrome Check Function for Linked Lists

2 participants