Skip to main content

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

  1. Serialize (tree nodes to list )
  2. Deserialize (list to tree nodes )
  3. Height (Finds height of the tree) and Diameter (Finds diameter of the tree)
  4. InOrderTraversal,PostOrderTraversal,PreOrderTraversal
  5. LevelOrderTraversal
  6. MirrorTree
  7. LeafNodes,NumberOfLeafNodes
  8. VisualizeTree

Installation

Python Version

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', '_', '_']
"""

Insertion IN BinarySearchTree(BST)

        
         
         100                               100
        /   \        Insert 40            /    \
      20     500    --------->          20     500 
     /  \                              /  \  
    10   30                           10   30
                                              \   
                                              40

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Contributors

  1. Samir Patil

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

easybt-0.0.7.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

easybt-0.0.7-py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page