From 1e8763bf41d912ccb1b73ab7c2ed72e20084935f Mon Sep 17 00:00:00 2001 From: Ahish Date: Fri, 5 Apr 2019 02:18:08 +0530 Subject: [PATCH] Update basic_binary_tree.py --- binary_tree/basic_binary_tree.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/binary_tree/basic_binary_tree.py b/binary_tree/basic_binary_tree.py index 5738e4ee114f..7c6240fb4dd4 100644 --- a/binary_tree/basic_binary_tree.py +++ b/binary_tree/basic_binary_tree.py @@ -4,6 +4,20 @@ def __init__(self, data): self.left = None self.right = None +def display(tree): #In Order traversal of the tree + + if tree is None: + return + + if tree.left is not None: + display(tree.left) + + print(tree.data) + + if tree.right is not None: + display(tree.right) + + return def depth_of_tree(tree): #This is the recursive function to find the depth of binary tree. if tree is None: @@ -41,6 +55,8 @@ def main(): # Main func for testing. print(is_full_binary_tree(tree)) print(depth_of_tree(tree)) + print("Tree is: ") + display(tree) if __name__ == '__main__':