A basic implementation of some data structures
Project description
This is very simple implementaion of Data Structure like Stack and Singly Linked List
- You can use the basic method of the Stack lik push, pop, peek, isEmpty, printStack. Here is the list:-
python
- push(val) #provide any valu as argument to push into stack
- pop() #It will pop or delete the top element of stack
- peek() #It will give you the top element
- isEmpty() #It will tell you whether the stack is empty or not
- printStack() #It will print the stack in form of list
Note:- if you initialize the stack size to 5 and you push only 3 element or less then 5 element then rest of the stack will print as 0 because initially all the value in stack is 0
-
In Singly Linked List you can use so many methods here is the list:-
1) len() 2) is_empty() #Make sure you use this method inside the print function 3) traverse() #To print the linked list 4) insertAtHead(val) #Provide any value as argument 5) insertAtTail(val) #Provide any value as argument 6) insertAtPos(val, pos) #First provide the value and then position 7) deleteHead() #It will delete the head node 8) deleteTail() #It will delete the tail node 9) deleteAtPosition(pos) #Provide the position of node you want to delete 10) insertAfter(val, newVal) #First provide the value after which you want to add a new value. E.g:- after 5 you want to add 6 then insertAfter(5, 6) 11) insertBefore(val, newVal) #First provide the value before which you want to add a new value. E.g:- before 5 you want to add 6 then insertBefore(5, 6) 12) get_tail() #It will print the tail node 13) get_head() #It will print the head node
Here is the exmaple
-
Stack
from DScollection import * #OR # from DScollection import Stack # from DScollection import SinglyLL s1 = Stack(5) #here 5 is the size of stack s1.push(1) s1.push(2) s1.push(3) s1.push(4) s1.push(5) #you can also use loop to push to avoid this number of lines s1.pop() s1.peek() s1.isEmpty() s1.printStack()
-
Singly Linked List
from DScollection import * #OR # from DScollection import Stack # from DScollection import SinglyLL l1 = SinglyLL() #here 5 is the size of stack l1.insertAtHead(5) l1.insertAtHead(6) l1.traverse()
I will update this with all the data structure with ready to use
Change Log
0.0.2 (30/8/2024)
-Second Release
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
DScollection-0.0.2.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for DScollection-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58fed2003859aa6642174642c536cddb23b9285bba6e66dc6bdf040650324aff |
|
MD5 | a81f5d4958615d59f6280ca35b8f1ce1 |
|
BLAKE2b-256 | 7ff10a6e2a85e508c1d594d5657e8b1047c68ae717934dfa3ffa52e6770192a0 |