Skip to main content

Implements Binary Search Trees, AVL Trees, Splay Trees, and Red Black Trees in Python with plotting.

Project description

About

PyBST implements Binary Trees, AVL Trees, Splay Trees, and Red Black Trees in Python. Furthermore, PyBST provides a module for plotting these trees using networkx and matplotlib.

Tree Classes Provided:

  • BSTree - represents an unbalanced Binary Search Tree

  • AVLTree - represents a balanced AVL Tree

  • SplayTree - represents an adjusted Splay Tree

  • RBTree - represents a balanced Red Black Tree

Constructor

Let Tree represent one of the provided tree classes mentioned above.

  • Tree() - > Creates a new empty tree

  • Tree(seq) -> Creates a new empty tree from seq [(key1,val1),(key2,val2),…,(keyn,valn)]

Methods

Tree Methods:

  • is_valid() -> Produces True if Tree is a valid tree of its type, else False.

  • preorder() -> Produces a sequence of the Nodes in Tree in preorder.

  • inorder() -> Produces a sequence of the Nodes in Tree in inorder.

  • postorder() -> Produces a sequence of the Nodes in Tree in postorder.

  • levelorder() -> Produces a sequence of the Nodes in Tree in levelorder.

  • get_node(key) -> Produces the Node in Tree with key attribute key.

  • insert(key,val) <==> Tree[key] = value. Inserts a new Node with key attribute key and value attribute val into Tree.

  • insert_from(seq) -> Inserts keys and values from seq [(key1,val1),(key2,val2),…,(keyn,valn)] into Tree.

  • get_max() <==> max(Tree). Produces the Node with the maximum key in Tree.

  • get_min() <==> min(Tree). Produces the Node with the minimum key in Tree.

  • get_element_count <==> len(Tree). Produces the number of elements in Tree.

  • get_height() -> Produces the height of Tree.

  • delete(key) <==> del Tree[key]. Deletes the Node with key attribute key from Tree.

  • delete_from(seq) -> Deletes Nodes with keys from seq [key1,key2,…,keyn] from Tree.

Plotting Methods (draw Module):

  • plot_tree(Tree) -> Provides a visual representation of Tree via plotting it using networkx and matplotlib.

Dependencies

PyBST requires no external dependencies for the tree classes and their methods themselves. However, note that the following packages are required for tree plotting:

Networkx: http://networkx.github.com/

Matplotlib: http://matplotlib.org/

Installation

From source:

python setup.py install

Using easy install:

easy_install pybst

Alternatively download one of the build distributions found under Downloads.

Documentation

See PyBST’s github repository at: https://github.com/TylerSandman/PyBST/

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

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

Source Distributions

pybst-1.0.zip (19.2 kB view details)

Uploaded Source

pybst-1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyBST-1.0.win32.msi (163.8 kB view details)

Uploaded Source

File details

Details for the file pybst-1.0.zip.

File metadata

  • Download URL: pybst-1.0.zip
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pybst-1.0.zip
Algorithm Hash digest
SHA256 620b60a4c1320cb3603f3bc385037c1869fecf6975c09a90683def6659cbefe0
MD5 3e16de734a4356013bb66d973fb7e5c2
BLAKE2b-256 d76e7814f75074c86c6a6157063c7ea45692061f5018c708a385a57781acdaf8

See more details on using hashes here.

File details

Details for the file pybst-1.0.tar.gz.

File metadata

  • Download URL: pybst-1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pybst-1.0.tar.gz
Algorithm Hash digest
SHA256 c7c3b248b9009c9ceb6e80565195de121e335cd58e6d2f2d08c8a7901ea56dc7
MD5 61e70e04f1422c3dabca34b9ab343b98
BLAKE2b-256 a85fd13a2feaea2770b97dc1879cd1ae922be1305fbb4d3412b4c974be8a2b79

See more details on using hashes here.

File details

Details for the file PyBST-1.0.win32.msi.

File metadata

  • Download URL: PyBST-1.0.win32.msi
  • Upload date:
  • Size: 163.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PyBST-1.0.win32.msi
Algorithm Hash digest
SHA256 14916e971cad5891904610b6132f222fb7a106b44501b029bd9af4ed1fd71e79
MD5 f1b7e6bb094a14c6c8ef889a758ef533
BLAKE2b-256 a9ec93a03df50cf3ce5f2750a83e693b2985e112fedc6ddbe77504042054324d

See more details on using hashes here.

Supported by

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