Skip to main content

A python library to handle dataStructures

Project description

updated: Monday, 24th January 2022
datastax

Simplicity meets intelligence

PyPI PyPI Downloads


dataStax

What's New?

  • Added Threaded Binary Trees
  • Added LRU Cache
  • Added Proper and effective testcases

Table of Contents

Introduction

  • This is a very simple yet powerful project to implement day to day abstract data structures
  • A pure implementation of Python in representing Tree, Linkedlist and Array based datastructures in basic command prompt
  • It helps visualize each data structure for better understanding
  • Students can be beneficial in using this Package
  • This project is still under construction

Problem Statement

  • Often at the beginning of B.Tech Course, CS students face a lot of problems understanding the internal architecture of complex ADTs.
  • While solving coding challenges locally where test cases have to be written using these ADTs, it becomes really cumbersome to write these data structures from scratch.
  • Also, when writing programs which implements these ADS, we encounter lots of errors just because we are unable to preview what's actually going on under the hood.

Benefits

  • Instant installation
  • Quick Updates
  • Very small size
  • No extra modules required
  • Written purely from scratch
  • Easy Documentation [Upcoming]
  • Command Line Demo

Requirements

  • Runs on latest Python 3.7+
  • (WARNING: Though the module might run on py 3.7 error free, but it has been tested for 3.9+)
  • (Suggesting you to always update to the latest python version)
  • This Library requires no extra modules

Installation

  1. Use the python package manager pip to install datastax.
pip install datastax

Usage

Demo

  • To get a demo of the library use the following command

    • Windows:
    > py -m datastax 
    
    • Unix based systems:
    $ python3 -m datastax
    
    • Result
    Available modules are:
    1. LinkedLists
    2. Trees
    3. Arrays
    
    Usage
    > py datastax <data-structure> [data]
    Data Structures:
    ->  trees          Hierarchical DS
    ->  linkedlists    Linear DS
    ->  arrays         Fixed Size Linear DS
    
  • Then follow as the instruction guides

> py -m datastax linkedlist 1 2 3 4
  Visuals for LinkedLists:

  1. Singly Linked List:
  Node[1] -> Node[2] -> Node[3] -> Node[4] -> NULL

  2. Doubly Linked List:
  NULL <-> Node[1] <-> Node[2] <-> Node[3] <-> Node[4] <-> NULL
  ...

Practical Usage

  • Queue
from datastax.arrays import Queue

# Building a Queue Data Structure with fixed capacity
queue = Queue(capacity=5)

# Enqueueing items inside queue
for item in ('item 1', 'item 2'):
    queue.enqueue(item)

# Performing Dequeue Operation 
queue.dequeue()

queue.enqueue('item 3')
print(queue)
$ OUTPUT:

         ┌──────────╥──────────┬──────────┐
FRONT ->            item 2    item 3   <- REAR
         └──────────╨──────────┴──────────┘
      

  • BinaryTree
from datastax.trees import BinaryTree

bt = BinaryTree([1, 2, 3, 4, 5])
print(bt)
$ OUTPUT:

             1           
       ┌─────┴─────┐     
       2           3     
    ┌──┴──┐              
    4     5              

  • MinHeapTree
from datastax.trees import MinHeapTree

MiHT = MinHeapTree([1, 2, 4, 2, 6, 5, 9, 18, 3, 2])
print(MiHT)
$ OUTPUT

                        1                       
            ┌───────────┴───────────┐           
            2                       4           
      ┌─────┴─────┐           ┌─────┴─────┐     
      2           2           5           9     
   ┌──┴──┐     ┌──┘                             
  18     3     6    

  • ThreadedBinaryTree
from datastax.trees import ThreadedBinaryTree as Tbt

tbt = Tbt(['a', 'b', 'c', 'd', 'e'], insertion_logic="BinaryTree")
print(tbt)
$ OUTPUT               
                                   ┌───┐
   ┌───────────────────────────> DUMMY │<──────────────┐
                              ┌───┴───┘                                             a                               
              ┌───────────────┴───────────────┐               
              b                             c               
      ┌───────┴───────┐              └───────┴───────┘        
      d             e                                       
   └───┴───┘       └───┴───┘                                    

What's Next

  • Implementation of Segment Trees
  • Proper tests using UnitTest Lib
  • Enhanced Documentation
  • Implementation of Other Abstract data types like LFU_CACHE, SKIP_LIST
  • Beautification of README.md

Upcoming

from datastax.trees import SumSegmentTree as St

st = St([1, 3, 5, 7, 9, 11])
print(st)
$ OUTPUT               
                       36                       
            ┌───────────┴───────────┐           
            9                      27           
      ┌─────┴─────┐           ┌─────┴─────┐     
      4           5          16          11     
   ┌──┴──┐     ┌──┴──┐                          
   1     3     7     9                          
                          

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datastax-0.2.0.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

datastax-0.2.0-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file datastax-0.2.0.tar.gz.

File metadata

  • Download URL: datastax-0.2.0.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for datastax-0.2.0.tar.gz
Algorithm Hash digest
SHA256 83e02e01966a16d9cbc258d6a97bf59282c60522efaaa0426de0ddaf6a8fa766
MD5 39bae38449cc5e029295c1ec0f94af2e
BLAKE2b-256 bae2f1bbf45fe4e7ee425cc5cccfb4719921ef6728a970bccba2ef911638ed3d

See more details on using hashes here.

File details

Details for the file datastax-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: datastax-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 26.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for datastax-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 269fecf829941d338b6ef55a86fe6b98397b89f671f272a77303fc02ce0cb0fe
MD5 a3483d25a8177aa65f0eb63ea6949560
BLAKE2b-256 4045113d8cd3d1970f428e1d54da35b29426ad6b14242641e90f8746a1aa64fd

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