Friday 29 December 2017

Implemention of Binary Tree using Python

Implemention of Binary Tree Using Python 

The Python code is according to python 2.7

In computer science, a binary tree is tree data structure in which each node has at most two childe,each one referred a left child and right child
Each node contain three parts :-
1)Address of node on his left size 2)Value stored by node 3)Address of node on his right size
The Tree Represention Is As :->

PYTHON CODES

Code For creating Binary Tree

This code is only for creating the tree .If u try to run this u don't get any output on terminal I Know gays....the code is bit large .but i try my best to mini. it.


Code For creating Binary Tree with Printing in diferrent form


I use Overloading in the printing the Triee in different form
  • In-Order
  • Pre-Order
  • Post-Order

Output:-

C:\Users\rushi\Desktop\mypyDec>python bt2.py No of node to add >6 Enter node value >70 >40 >80 >15 >50 >75 Print Tree in IN-ORDER :- 15 40 50 70 75 80 Print Tree in Pre-Order :- 70 15 40 50 75 80 Print Tree in Post-Order :- 15 40 50 75 80 70 C:\Users\rushi\Desktop\mypyDec>

No comments:

Post a Comment

IT's Good