Skip to main content

Simple Binary Tree Data Structure Implementation

Project description

pytreelib: Simple Binary Search Tree implementation


This package provides classes that implements Tree data structure and it’s variants.

BinaryTreeNode contains a data element value and references for parent, right and left child.

BinarySearchTree implements a Binary Search Tree data structure. Offers basic functions (insert, delete, search, status, display).


To create a node:

>>> from pytreelib import BinaryTreeNode
>>> node = BinaryTreeNode(10)
>>> print(node.value)  # 10

We can create BST in following ways:

an empty tree:

>>> from pytreelib import BinarySearchTree
>>> tree = BinarySearchTree()

with only root defined:

>>> from pytreelib import BinaryTreeNode, BinarySearchTree
>>> tree = BinarySearchTree(10)
>>> tree = BinarySearchTree(BinaryTreeNode(10))

with list of ints

>>> from pytreelib import BinarySearchTree
>>> tree = BinarySearchTree([10, 9, 8])
>>> print(tree.root)  # BinaryTreeNode:10
>>> print(tree.root.left)  # BinaryTreeNode:8
>>> print(tree.root.right)  # BinaryTreeNode:9


Currently it runs only with python3. Install this package via pip3.

$ pip3 install pytreelib


Version 0.1.1 [2018-12-12]
  • Initial Release

Project details

Release history Release notifications

Download files

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

Files for pytreelib, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size pytreelib-0.1.1-py3-none-any.whl (4.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pytreelib-0.1.1.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page