Simple implementation of data structures for python
Project description
pyfds
Simple implementaion of data structures (DS) for python
Content
- linked list
- doubly linked list
- sorted linked list
- stack
- queue
- priority queue
- binary search tree
- utils // (package)
Content of utils
- node // single pointer node
- dnode // double pointer node
- tnode // tree pointer node
- pair
how to import utils
from pyfds.utils import *
pair = Pair()
or
import pyfds.utils
pair = utils.Pair()
Classes
- List // linked list
- DList // doubly linked list
- SList // sorted linked list
- Stack // stack
- Queue // queue
- PQueue // priority queue
- BST // binary search tree
API
List
Properties
- first // TODO: return the data in the first node
- last // TODO: return the data in the last node
Methodes
- insert(data, pos) // TODO: add node in the entered position (pos=0 => add in the begining) // the default value is set to 0
- append(data) // TODO: add node in the end
- delete(data) // TODO: delete all nodes hav the entered data
- remove(pos=0) // TODO: return and remove node in the entered position (pos=0 => remove first node, pos=-1 => remove last node)
DList
Properties
- first // TODO: return the data in the first node
- last // TODO: return the data in the last node
Methodes
- add_begin(data) // TODO: add a node to the begin
- add_fin(data) // TODO: add a node to the fin
- delete(data) // TODO: delete all nodes hav the entered data
- remove(pos) // TODO: return and remove node in the entered position (pos=0 => remove first node, pos=-1 => remove last node) // the default value is set to 0
SList
Properties
- first // TODO: return the data in the first node
- last // TODO: return the data in the last node
Methodes
- append(data) // TODO: add a node to the list in a sorted way
- delete(data) // TODO: delete all nodes hav the entered data
- remove(pos) // TODO: return and remove node in the entered position (pos=0 => remove first node, pos=-1 => remove last node) // the default value is set to 0
Note
- the (reverse, sort, exchange) are not supported in this DS because they brake the rule of the Sorted Linked List
Stack
Properties
- top // TODO: return the data in the first node
Methodes
- push(data) // TODO: add a node to the top
- pop() // TODO: return and remove the node in the top
Queue
Properties
- front // TODO: return the data in the first node
- back // TODO: return the data in the last node
Methods
- enqueue(data) // TODO: add a node to the end
- dequeue() // TODO: return and remove the first element
PQueue
Properties
- front // TODO: return the data in the first node
- back // TODO: return the data in the last node
Methods
- enqueue(data) // TODO: add a node to the queue in a sorted way
- dequeue() // TODO: return and remove the first element
Methods for all DSs
- str() // USE: print([DS_name]) // TODO: display the DS
- len() // USE: len([DS_name]) // TODO: return the lenth of the DS
- empty() // TODO: return True if the DS is empty
- clear() // TODO: clear the DS
- find(data) // TODO: return the number of how many the entered data found in the DS
- reverse() // TODO: return the reverse of the DS
- sort() // TODO: sort the DS if its not sorted
- exchange(n) // TODO: circular permutation for n time
classmethods for all DSs
// USE: [DS] = [DS_type].method([DS1], [DS2])
// Examples:
stck3 = Stack.merge(stck1, stck2)
Stack.swap([DS1], [DS2])
the tow DS parameters must be from the same DS
- merge(DS1, DS2) // TODO: return the merge of two DS in new DS
- swap(DS1, DS2) // TODO: swap between DS1 and DS2 (DS1 will be DS2 and DS2 will be DS1)
BST
properties
- pre_order // TODO: represent the BST in pre_order way
- in_order // TODO: represent the BST in in_order way
- post_order // TODO: represent the BST in post_order way
- number_of_nodes // TODO: return the number of nodes in the BST
- number_of_liefs // TODO: return the number of liefs (nodes without any children) in the BST
- height // TODO: return the height of the BST
- max // TODO: return the maximum value in the BST
- min // TODO: return the minimum value in the BST
methodes
- append(data) // TODO: append a new node to the BST if not exist
- find(data) // TODO: search for an element in the BST and return it if exist
- parent(data) // TODO: return the parent node of an element if exist
- successor(data) // TODO: return the next value in the BST if exist
- predecessor(data) // TODO: return the previous value in the BST if exist
- delete(data) // TODO: delete an element from the BST if exist
classmethodes
- equals(bst1, bst2) // TODO: return True if bst1 is equal to bst2 (bst1 is the same as bst2)
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
py-fds-3.4.2.tar.gz
(7.3 kB
view details)
Built Distribution
py_fds-3.4.2-py3-none-any.whl
(23.7 kB
view details)
File details
Details for the file py-fds-3.4.2.tar.gz
.
File metadata
- Download URL: py-fds-3.4.2.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.6rc1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31bcb3172d2c4880cfef8b47a7a42a429d8e3976b2b6617059020d72755d3d04 |
|
MD5 | 3b9d4edf82b07ecae08a246c45656ef6 |
|
BLAKE2b-256 | 26f4a1bbacb2897e776ebc6649a402334a797aa2942110771e01f64ebf5c44cd |
File details
Details for the file py_fds-3.4.2-py3-none-any.whl
.
File metadata
- Download URL: py_fds-3.4.2-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.6rc1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59238894274364310680df86018ff0d96b63afdbd7acb57a5b014a68dec467d6 |
|
MD5 | 6518cd090fa8e02de9761f5133562229 |
|
BLAKE2b-256 | db7bba183bb002e49414e00597dd7e5d69bb662431080fe85ea60f652b715858 |