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
Project details
Release history Release notifications | RSS feed
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.0.tar.gz
(17.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_binary_tree-1.0.0.tar.gz.
File metadata
- Download URL: python_binary_tree-1.0.0.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25e1e1b7dc79b1d37ac3a191ef28142405a54477b08975dc35840b87d439f717
|
|
| MD5 |
5376452b5eaf08193f74cf12a3201202
|
|
| BLAKE2b-256 |
d507ef2b219dadf35118be82bc67658e58ee266cab84276eb3ea9fc9a6a8882e
|
File details
Details for the file python_binary_tree-1.0.0-py3-none-any.whl.
File metadata
- Download URL: python_binary_tree-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63ed048fc4cc4e38ddbb0403f164f2f1628a3e2b694e43092523618105ac8168
|
|
| MD5 |
25fb6e8e7a13d1e32a129014e525bf8f
|
|
| BLAKE2b-256 |
a721bbe9fa85b4da8fa8496c4b22602f188b6cf34cafd5c988f4d47b94a7e24a
|