Library for Studying Tree Data Structure
Project description
Library for Studying Tree Data Structure
Installation
pip install treekit
Sample Usage
>>> from treekit import binarytree >>> bt1 = binarytree([13, 3, 14, 0, 4, None, None, None, 2, None, 7]) # data array in breadth-first order, see: https://en.wikipedia.org/wiki/Binary_tree#Arrays >>> bt1.show() # this will create an output.html and open a tab in web browser to view it >>> bt1.height 3 >>> bt1.inorder # bt.preorder # bt.postorder # bt.levelorder [0, 2, 3, 4, 7, 13, 14] >>> bt1.preorder [13, 3, 0, 2, 4, 7, 14] >>> bt1.flatten(target="preorder", inplace=True) >>> bt1.inorder [13, 3, 0, 2, 4, 7, 14] >>> bt1.preorder [13, 3, 0, 2, 4, 7, 14]
>>> from treekit import bst >>> bst1 = bst(h=4) >>> bst1.show()
Sample Screenshot
Binary Search Tree, height = 4
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
treekit-0.0.9.tar.gz
(74.9 kB
view hashes)
Built Distribution
treekit-0.0.9-py3-none-any.whl
(73.4 kB
view hashes)