Let’ s first see the definition

PWA(Progressive web app) is a way to design the web applications, that gives the experience like native application(mobile application).

Before starting the detail discussion, one thing you must keep in mind that PWA(Progressive web app) is not any technology or tools, You will be…

Tree is a hierarchical data structure. One instance of tree is Binary tree, in which each node has maximum two child.

Following program implement the complete binary tree with single method call.

class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None


class BinaryTree:

def __init__(self):
self.root = None

def create_tree(self):
data = int(input('enter root node'))
if data == -1:
return
new_node = Node(data)
self.root = new_node
self.create_lefttree(new_node)
self.create_righttree(new_node)
def create_lefttree(self,node):
data = int(input('Enter the left child of {0}'.format(node.data)))
if(data == -1):
return
new_node = Node(data)
self.create_lefttree(new_node)
node.left = new_node
self.create_righttree(new_node)
return
def create_righttree(self,node):
data = int(input('enter the right child of {0}'.format(node.data)))
if data == -1:
return
new_node = Node(data)
self.create_righttree(new_node)
node.right = new_node
self.create_lefttree(new_node)
return
binaryTree = BinaryTree() #creating one instance of BinaryTree
binaryTree.create_tree()

Tarun Singh

foresighted | futuristic | barrier free thought

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store