Operations On Binary Tree
Project description
EasyBT
Make Binary trees easy for everyone it is used to serialize-deserialize binary trees and performs much more operations
- Serialize (tree nodes to list )
- Deserialize (list to tree nodes )
- Height (Finds height of the tree) and Diameter (Finds diameter of the tree)
- InOrderTraversal,PostOrderTraversal,PreOrderTraversal
- LevelOrderTraversal
- MirrorTree
- LeafNodes,NumberOfLeafNodes
- VisualizeTree
Installation
Use the package manager pip to install easybt.
pip install easybt
Usage
from easybt.binarytree import BinaryTree
# Create Object
bt=BinaryTree()
# add nodes in list
nums=[1,2,None,None,5,6]
# it will return root node of the tree
root=bt.DesializeTree(nums)
Examples
[1,2,3,4,5,6] [1,2,None,4,5,6]
1 1
/ \ /
2 3 2
/\ / / \
4 5 6 4 5
/
6
Documetation
Visualize Tree
from easybt.binarytree import BinaryTree
# Create Object
bt=BinaryTree()
# add nodes in list
nums=x=[1,2,3,4,5,6]
# it will return root node of the tree
root=bt.DesializeTree(nums)
VisualizeTree(root)
#it will print
"""
['_', '_', '1', '_', '_']
['_', '2', '_', '3', '_']
['4', '_','5,6', '_', '_']
"""
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Contributors
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
easybt-0.0.5.tar.gz
(4.1 kB
view hashes)
Built Distribution
easybt-0.0.5-py3-none-any.whl
(5.0 kB
view hashes)