A python library to handle dataStructures
Project description
updated: Thursday, 24th February 2022
dataStax
What's New?
- Added Sum Segment Tree
- Added Min Segment Tree
- Added Huffman Tree
- data encoder
- data decoder
- Huffman Code
- Huffman Table
- compression ratio
- space saved
- Added Red Black Tree - ๐ธ TESTED
- Added Splay Tree - ๐ธ TESTED
- Added Delete methods in: ๐ธ TESTED
- BinaryTree
- BinarySearchTree
- AVLTree
- Enhanced string representation of all LinkedLists
- Added Custom Comparator for PriorityQueue
- Added name-mangler function for items with multiline string representations
- Added HuffmanTable object for storing and visualizing huffman-table
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
- 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:
HEAD TAIL
โโโโโโโฅโโโโโ โโโโโโโฅโโโโโ โโโโโโโฅโโโโโ โโโโโโโฅโโโโโ
โ 1 โ ----->โ 2 โ ----->โ 3 โ ----->โ 4 โ -----> NULL
โโโโโโโจโโโโโ โโโโโโโจโโโโโ โโโโโโโจโโโโโ โโโโโโโจโโโโโ
2. Doubly Linked List:
HEAD TAIL
โโโโโโฅโโโโโโฅโโโโโ โโโโโโฅโโโโโโฅโโโโโ โโโโโโฅโโโโโโฅโโโโโ โโโโโโฅโโโโโโฅโโโโโ
NULL <----- โ 1 โ <-------> โ 2 โ <-------> โ 3 โ <-------> โ 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
logic = str("BinaryTree")
tbt = Tbt(['a', 'b', 'c', 'd', 'e'], insertion_logic=logic)
print(tbt)
$ OUTPUT
โโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ> DUMMY โ<โโโโโโโโโโโโโโโ
โ โโโโโดโโโโ โ
โ a โ
โ โโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโ โ
โ b โ โ c โ
โ โโโโโโโโโดโโโโโโโโ โ โโโโโโโโโดโโโโโโโโ
โ d โ โ e โ
โโโโโดโโโโ โโโโโดโโโโ
- SumSegmentTree
from datastax.trees import SumSegmentTree
sst = SumSegmentTree([1, 3, 5, 7, 9, 11])
print(sst)
print(sst.preorder_print())
$ OUTPUT
36
[0:5]
โโโโโโโโโโโโโดโโโโโโโโโโโโ
9 27
[0:2] [3:5]
โโโโโโโดโโโโโโ โโโโโโโดโโโโโโ
4 5 16 11
[0:1] [3:4]
โโโโดโโโ โโโโดโโโ
1 3 7 9
36 [0:5]
โโโถ 9 [0:2]
โ โโโถ 4 [0:1]
โ โ โโโถ 1
โ โ โโโถ 3
โ โโโถ 5
โโโถ 27 [3:5]
โโโถ 16 [3:4]
โ โโโถ 7
โ โโโถ 9
โโโถ 11
- HuffmanTree
from datastax.trees import HuffmanTree
string = str("Espresso Express")
hft = HuffmanTree(string)
print(hft)
$ OUTPUT
16
0 โ 1
โโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโ
7 9
0 โ 1 0 โ 1
โโโโโโโโโโโโโดโโโโโโโโโโโโ โโโโโโโโโโโโโดโโโโโโโโโโโโ
3 4 4 s
0 โ 1 0 โ 1 0 โ 1 5
โโโโโโโดโโโโโโ โโโโโโโดโโโโโโ โโโโโโโดโโโโโโ
x 2 e r E p
1 0 โ 1 2 2 2 2
โโโโดโโโ
o
1 1
- RedBlackTree
from datastax.trees import RedBlackTree
rbt = RedBlackTree([500, 236, 565, 105, 842, 497, 312, 612, 80])
rbt.delete(236)
print(rbt)
$ OUTPUT
500
โโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโ
105 612
โโโโโโโโโโดโโโโโโโโโ โโโโโโโโโโดโโโโโโโโโ
80 497 565 842
โโโโโ
312
What's Next
- Enhanced Documentation
- Better TestCases for Huffman Tree
- Better TestCases for Segment Trees
- Test Cases for Fibonacci Tree
- Adding of images of trees instead of trees themselves in README
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
datastax-0.3.0.tar.gz
(25.6 kB
view details)
Built Distribution
datastax-0.3.0-py3-none-any.whl
(32.9 kB
view details)
File details
Details for the file datastax-0.3.0.tar.gz
.
File metadata
- Download URL: datastax-0.3.0.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d37582a56778fb0a67307f39aa6bc8fe69d5051685e50340f60358e792d2150d |
|
MD5 | e4bb87eb918f1762fc2c30a828c7b93e |
|
BLAKE2b-256 | f684aa6174e420ecf9e0e9c3675974e4a69d6dc848534172d3842de8f05177ef |
File details
Details for the file datastax-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: datastax-0.3.0-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 027f1059cda8fdbdd47bc0925dd250d52ba94460af0809ea4b33b2e136a0208e |
|
MD5 | 9c28815bc76193c9f785aefa1b0f5865 |
|
BLAKE2b-256 | 09a09d0cbcbec71e018b2791ae5f11dc461fa5c21b8f33e957945dd490c62f88 |