PRE-ALPHA - UNDER DEVELOPMENT
| Badges: | |
|---|---|
| CI: | |
| Downloads: | http://pypi.python.org/pypi/datastructures |
| Source: | https://github.com/quantmind/datastructures |
| Keywords: | data structures set tree list |
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() # 2Insert 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()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]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 verticesSpeedy functions for every day use
from datastructures import factorial