Skip to main content

Binary tree implementation for Python

Project description

python-binary-tree

A simple implementation of a binary tree in Python.

Installation

pip install python-binary-tree

Usage

from binary_tree.BinaryTree import BinaryTree
from binary_tree.BinaryTreeNode import BinaryTreeNode
# Create a binary tree and add nodes
bt = BinaryTree()
# Create nodes with values
root = BinaryTreeNode(0)
node1 = BinaryTreeNode(1)
node2 = BinaryTreeNode(2)
node3 = BinaryTreeNode(3)
node4 = BinaryTreeNode(4)
node5 = BinaryTreeNode(5)

# Add relationships between nodes
root.add_left(node1)
root.add_right(node2)

node1.add_right(node3)
node2.add_right(node4)
node1.add_left(node5)

# Insert nodes into the binary tree
bt.insert(root)
bt.insert(node1)
bt.insert(node2)

bt.draw()

Example Output

exampleplot.png

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

python_binary_tree-1.0.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

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

python_binary_tree-1.0.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file python_binary_tree-1.0.1.tar.gz.

File metadata

  • Download URL: python_binary_tree-1.0.1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for python_binary_tree-1.0.1.tar.gz
Algorithm Hash digest
SHA256 44afed6d39280a284e831fd27c69b304d688ac3f3a8835602d3979229492b379
MD5 ccde97350947ebed0e3fd6376963abd7
BLAKE2b-256 ccadbfc25d84373111245a27240dc2ff1d5194f51d882518243630465404314b

See more details on using hashes here.

File details

Details for the file python_binary_tree-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for python_binary_tree-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6455ba759c6981bd9fddade72b7b8843a4d400091a30d474be62cfa20ef778a8
MD5 ec30328a0bfc6fa806ea552f43609ab8
BLAKE2b-256 d176d3ae5e8422d0069a6b9cd0970f4804b13658a92a28a00516f0176d6a1e2d

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