Some useful and known data structure.
Project description
Data Structures for python
- Linked List
- Singly Linked List
- Circularly Singly Linked List
- Doubly Linked List
- Circularly Doubly Linked List
- Stack
- Stack using list
- Stack using linked list
- Queue
- Queue
Installation
Latest Version : 0.1.0
pip install Gsauce-pyds
License
© 2021 Rajarshi Banerjee
This repository is licensed under the MIT license. See Licence for details.
Link to package
How to use?
- Import the pacakge
from dstructure import *
Singly Linked List
from dstructure import *
L_list= SLL()
- Insert into linked list
from dstructure import *
L_list= SLL()
L_list.push(1)
L_list.push(2)
L_list.push('word')
L_list.printList()
# Output:
# Head--> 1 --> 2 --> word --> Null
# push(value,index=-1)
# index = -1 --> insert at the end of the list
# index = 0 --> insert at the beginning
# index = 5 --> insert element at location/index 5
# Note: 0 based index
- Deletion
L_list.delete() # this will delete the last element
L_list.delete(0) # will delete the first element
L_list.delete(4) # will delete element at index 4
Note: delete() takes one argument index
which is by default set to -1, i.e. delete(index=-1)
| -1 means it will delete the element from the end.
- list.len
print(L_list.len) # will print the length of the linked list
- Reverse()
L_list.reverse() # will reverse the linked list
# reverse() function returns NONE
- get_node()
# To extract the data of a specific node
L_list.get_node(i) # to collect the ith node.data
# returns the data of a specific index.
Circularly singly linked list
Relevant Functions are given below:
push(value,index)
'''Inserts values at given index | Default value of index is set to -1
which means value will be appended at the end.
Indexing is 0 based. | returns None'''
pop(index)
'''Default value of the index is set to -1 | returns the data after
deleting the specified node at given index.'''
printList()
'''Prints the entire list'''
#example
l=CircularList([1,2,3,4])
print(l.len) # returns the size of the list
l.printList()
#OUTPUT:
# 4
# Head--> 1--> 2--> 3--> 4--> Null
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Gsauce-pyds-0.2.0.tar.gz
(8.3 kB
view hashes)
Built Distribution
Close
Hashes for Gsauce_pyds-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a089ce401653fdcb10c13399c146e0d57fb300e0f0fff96f3c9ce59d4a3be9e3 |
|
MD5 | 3fd152e86fc7c6f82256afafd6d41eff |
|
BLAKE2b-256 | 3ba0875f5870900efe99e1ecad6b59f5f70821cde79dbbe6497cab7c1234760b |