Skip to main content

A simple linked list implementation in Python

Project description

Linked List Package

A simple implementation of a singly linked list in Python.

Features

  • Insert elements at the beginning (insert_left)
  • Insert elements at the end (insert_right)
  • Insert elements at a specific position (insert_at)
  • Delete elements from the beginning (del_left)
  • Delete elements from the end (del_right)
  • Display the linked list (show)
  • Merge two linked lists (merge)
  • Get the length of the linked list (len)

Installation

Install Linked_list with pip

    pip install PyLinkedList2905

Usage

insert elements

from PyLinkedList2905 import Linked_list

# Create a new linked list
ll = Linked_list()

# Insert elements at the left (beginning)
ll.insert_left(10)
ll.insert_left(20)

# Insert elements at the right (end)
ll.insert_right(30)

# Insert elements at a specific position
ll.insert_at(1, 25)

# Show the linked list
ll.show()

output

20-->10-->25-->30-->None

delete elements

# Delete an element from the left (beginning)
ll.del_left()

# Delete an element from the right (end)
ll.del_right()

# Show the linked list after deletions
ll.show()

merge two linked list

# Create another linked list
ll2 = Linked_list()
ll2.insert_left(40)
ll2.insert_right(50)

# Merge the second list into the first list
ll.merge(ll2)

# Show the merged linked list
ll.show()

output

10-->25-->30-->40-->50-->None

Get the Length of the Linked List

# Get the length of the linked list
print("Length of the list:", ll.len())

output

Length of the list: 5

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylinkedlist2905-0.1.4.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyLinkedList2905-0.1.4-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file pylinkedlist2905-0.1.4.tar.gz.

File metadata

  • Download URL: pylinkedlist2905-0.1.4.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.6

File hashes

Hashes for pylinkedlist2905-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e7d7ef26cb5e2c1c57340eaebd7e6c9d6fbe9ce55f342c0107420ba4d4b28738
MD5 fc9e97ca5986dfdd8b2f9c66213ee662
BLAKE2b-256 550f056584bcb49bf071e4923bac2a701c4e5d69ad18406635d527445932fb7d

See more details on using hashes here.

File details

Details for the file PyLinkedList2905-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for PyLinkedList2905-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7bbecfbeeaf85a7660dbb11f720d575b0c107261d3b0216495cf131009329e2a
MD5 b7ca4a56b8f197ff4fb6fc08ba3d5e5d
BLAKE2b-256 c75448feecafab85af63a90b1b86f9276287c6064fb5c50c5a58bafbba0541db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page