/datastructures

Data Structures

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Data Structures

PRE-ALPHA - UNDER DEVELOPMENT

Badges:license pyversions status pypiversion
CI:ci cover
Downloads:http://pypi.python.org/pypi/datastructures
Source:https://github.com/quantmind/datastructures
Keywords:data structures set tree list

Binary Tree

A binary tree implementation is available:

from datastructures import Tree, Node

tree = Tree()
tree.size()        # 0
tree.max_depth()   # 0
tree.root          # None
root = tree.add()  # Node
root.left = Node()
tree.size()        # 2
tree.max_depth()   # 2

Insert a value assumes the binary tree is a binary search tree (BST) and uses the AVL algorithm to keep the tree self-balancing.

tree.insert(56)

To check if the tree is a binary search tree:

tree.is_bst()

Skiplist

from datastructures import Skiplist

sl = Skiplist()
len(sl)                   # 0
sl.insert(43)             # insert a new value
len(sl)                   # 1
sl.extend([6, 3, 6, 2])   # extend with an iterable
sl                        # [2.0, 3.0, 6.0, 6.0, 43.0]

Graph

A graph is not strictly a data structure, it is a custom class for implementing grph algorithms.

from datastructures import Graph

graph = Graph()
graph.add_edges(((0, 1), (3, 4), (2, 3)))
graph.vertices      // dictionary of vertices

Functions

Speedy functions for every day use

from datastructures import factorial