
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
A Python package with simple implementation of a singly linked list with various utility functions.
A simple implementation of a singly linked list with various utility functions.
You can install the package via pip:
pip install singly_linked_list
Here’s a quick example of how to use the SinglyLinkList class:
from singly_linked_list import SinglyLinkList
# Create a new linked list
linked_list = SinglyLinkList()
# Add elements
linked_list.push(10) # Add to front
linked_list.append(20) # Add to end
linked_list.insert(10, 15) # Insert after 10
# Print the list
print(linked_list.printList()) # Output: [15, 10, 20]
# Remove an element
linked_list.remove(10)
print(linked_list.printList()) # Output: [15, 20]
The SinglyLinkList class provides methods for manipulating linked lists as described in the features section. Each method has its own functionality:
Initialization: SinglyLinkList()
Add Nodes:
push(data):
Add a new node at the beginning.append(data):
Add a new node at the end.insert(after_element, data):
Insert a new node after a specified element.Remove Nodes:
remove(element):
Remove the first occurrence of an element.delete():
Delete the entire linked list.Traversal and Querying:
printList():
Return a list of node values.length():
Return the number of nodes in the list.getNth(n):
Get the nth node's data.getNthFromLast(n):
Get the nth node's data from the end.Utilities:
isPalindrome():
Check if the list is a palindrome.checkLoop():
Check for loops in the list.lengthOfLoop():
Find the length of a loop if it exists.uniqueSorted():
Retrieve unique elements in sorted order.Modify List:
reverseList():
Reverse the order of nodes.segregateEvenOdd():
Separate even and odd nodes.Merging Lists:
mergeTwoLists(l1, l2):
Merge two sorted linked lists.Contributions are welcome! Please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License.
FAQs
A Python package with simple implementation of a singly linked list with various utility functions.
We found that py-linked-list demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.