Skip to main content

Simple implementation of data structures for python

Project description

pyfds

Simple implementation of data structures (DS) for python.

This package no more supported and will not get new updates, see PyAlStruct for new implementation of algorithms and data structures.

Content of the library

  • 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
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
  • equals(DS) // TODO: return True if DS is equal to this DS
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 DSs in new DS
  • swap(DS1, DS2) // TODO: swap between DS1 and DS2 (DS1 will be DS2 and DS2 will be DS1)

Note :

(reverse, sort, exchange) are not supported in this DS because they brake the rule of the Sorted Linked List

BST
properties
  • 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
  • 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
  • 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
  • equals(bst) // TODO: return True if bst is equal to this BST (this BST is the same as bst)

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

py-fds-3.5.3.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

py_fds-3.5.3-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file py-fds-3.5.3.tar.gz.

File metadata

  • Download URL: py-fds-3.5.3.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for py-fds-3.5.3.tar.gz
Algorithm Hash digest
SHA256 0b757c4ad5ef19c143dae2a9943c63e5add2ec458d4a23aac5eeacbff899a051
MD5 7d525b702cecd49e80dec8f3b5eff2e2
BLAKE2b-256 b57d819b5ed8841fcb4c6fa69e3baf731e82bbf6df32572e112648ca18b21a7e

See more details on using hashes here.

File details

Details for the file py_fds-3.5.3-py3-none-any.whl.

File metadata

  • Download URL: py_fds-3.5.3-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for py_fds-3.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 467e0b92912e6efe4ce4f23c29a44bd4827eeef0e41e54f8ce2c8b1a65e70a75
MD5 a1737438448687f4d6245ecff5670d79
BLAKE2b-256 356b9f67e8f17772e01981590db13d35567ebe6bccf4e62e81472ae6b7f15194

See more details on using hashes here.

Supported by

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