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.0.6
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.1.0.tar.gz
(7.2 kB
view hashes)
Built Distribution
Close
Hashes for Gsauce_pyds-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb15d588ba2afb320615dbdb94ed18604788fe35e2047412cb89c9579cc5a7cc |
|
MD5 | 35e993cc1469212f8ee73901f0ba9258 |
|
BLAKE2b-256 | 7213f4879275e4a6cf63405df44f4f557f129fa9646f71e6ef8d538f5a421112 |