Skip to main content

A python package for data structures and algorithms.

Project description

datlib

This is a python package containing useful classes and functions of data structures and algorithms.

Installation

Run the following to install:

'''python

pip install datlib

'''

Usage

There are many modules inside this package.

###1. rangeQueries module

  This module contains a class name SegmentTree.
  The constructor of the class takes following arguments :

  (a) A function **combine**
      This takes two arguments a and b. This function takes care of 
      the combination of the values of child nodes into a parent node.


  (b) A variable **identityVal**

      An identity value for filling the empty nodes in the segment tree
      array and for the case when the query is completely outside the 
      range.

  (c) A list **l**

      This contains the list for which you have to make the SegmentTree.

  You can make the segment tree in following way : 

  '''python

     from rangeQueries import SegmentTree
     def combine(a,b):
         return a+b

     l = [1,2,3,4,5,6,7,8]
     identityVal = 0
     s = SegmentTree(l,identityVal,combine)

  '''

  You can call following methods on your segment tree :

  (a) query(qs,qe)

      This method will take two parameters qs and qe. And will perform 
      query for the range.

  (b) pointUpdate(val,qi)

      This method will take two parameters qi and val,where qi is the 
      index of the given list **l** on which we will update the value
      to **val**.This will update the your segment tree.

  (c) rangeUpdate(qs,qe,val)

      This method will take three parameters qs,qe and val.This method
      will update the values to **val** from index **qs** to **qe**.
      This will update the your segment tree.

###2. numbertheory module

  This module contains following functions :
  Here **n** is the number.

  (a) primefactors(n)

      This function will return all the prime factors of a number.

  (b) chkPrime(n)

      This function will check if a number is prime or not.

  (c) divisors(n)

      This function will return all the divisors of a number.

  (d) powerModulo(x,y,M)

      This function will calculate x^y modulo M.

###3. graphs module

  This module contains following functions :


  (a)  bfs(start,graph)

       This function will take two arguments start and graph.
       Start is the source node which can be a tuple,number or a string.
       graph is a dictionary which contains the adjacency list of the nodes.
       This function will return a dictionary containing distance of all the
       nodes from the source node.

  (b) dfs(start, graph)

      This function will take two arguments start and graph.
      Start is the source node which can be a tuple,number or a string.
      graph is a dictionary which contains the adjacency list of the nodes.
      This function will contain a set of all the nodes that can be reched
      from start.

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

datlib-0.0.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

datlib-0.0.3-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file datlib-0.0.3.tar.gz.

File metadata

  • Download URL: datlib-0.0.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.3

File hashes

Hashes for datlib-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a1ddbc01a73bc2567b5fe31018821b5f1a273feedd22efb8706be354080d3d84
MD5 503d232ec97763dbd9ca5441410a44f3
BLAKE2b-256 8c2d67b81417b499c7f67de6947e62830c7e14b240a77aa325c78a2a42643d7e

See more details on using hashes here.

File details

Details for the file datlib-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: datlib-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.3

File hashes

Hashes for datlib-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 914924c2078b7db5c0e9f92574d7e1b784a0fd2439345bca9e77a7bfeb3d7050
MD5 796c38cf59f7e5fb775431dbb11b11bc
BLAKE2b-256 48368512cf1eea03a14d48b080c35e0ecd368db612c9a89afadb3d46100946f3

See more details on using hashes here.

Supported by

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