Skip to main content

Simple implementation of data structures for python

Project description

fds

Simple implementaion of data structures (DS) for python

Content

  • linked list
  • doubly linked list
  • sorted linked list
  • stack
  • queue

Classes

  • List // linked list
  • DList // doubly linked list
  • SList // sorted linked list
  • Stack // stack
  • Queue // queue

API

List

Properties

  • first(self) // TODO: return the data in the first node
  • last(self) // TODO: return the data in the last node

Methodes

  • insert(self, data, pos=0) // TODO: add node in the entered position (pos=0 => add in the begining)
  • append(self, data) // TODO: add node in the end
  • delete(self, data) // TODO: delete all nodes hav the entered data
  • remove(self, 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(self, data) // TODO: add a node to the begin
  • add_fin(self, data) // TODO: add a node to the fin
  • delete(self, data) // TODO: delete all nodes hav the entered data
  • remove(self, pos=0) // TODO: return and remove node in the entered position (pos=0 => remove first node, pos=-1 => remove last node)

SList

Properties

  • first // TODO: return the data in the first node
  • last // TODO: return the data in the last node

Methodes

  • append(self, data) // TODO: add a node to the list in a sorted way
  • delete(self, data) // TODO: delete all nodes hav the entered data
  • remove(self, pos=0) // TODO: return and remove node in the entered position (pos=0 => remove first node, pos=-1 => remove last node)

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(self, data) // TODO: add a node to the top
  • pop(self) // 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(self, data) // TODO: add a node to the end
  • dequeue(self) // TODO: return and remove the first element

Methods for all DSs

  • str(self) // USE: print([DS_name]) // TODO: display the DS
  • len(self) // USE: len([DS_name]) // TODO: return the lenth of the DS
  • empty(self) // TODO: return True if the DS is empty
  • clear(self) // TODO: clear the DS
  • find(self, data) // TODO: return the number of how many the entered data found in the DS
  • reverse(self) // TODO: return the reverse of the DS
  • sort(self) // TODO: sort the DS if its not sorted
  • exchange(self, 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(cls, DS1, DS2) // TODO: return the merge of two DS in new DS
  • swap(cls, DS1, DS2) // TODO: swap between DS1 and DS2 (DS1 will be DS2 and DS2 will be DS1)

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-2.2.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

py_fds-2.2.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py-fds-2.2.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for py-fds-2.2.0.tar.gz
Algorithm Hash digest
SHA256 17f87a2ed6924c4487d089344bb248982e2eac1a0082767471faf5f7ebb44787
MD5 426264d2518efc6ceb0443c0d1228ecb
BLAKE2b-256 35e37f75d5dbb94370359441500b1bccdf505b16a0cc6d8ebb2201f616b98145

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_fds-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for py_fds-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b014b8c95a019ab951056acfba2a59fa0e2b1ab6a8983f0bb21a1e4219b1fe84
MD5 3cc103d4c34a461376b396d1c1b4bf91
BLAKE2b-256 a427f45729330e37aa630b00ff402dc99efe35315b84229496124b6b11147197

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