Skip to content

Commit 56de3df

Browse files
Ahish9009poyea
authored andcommitted
Update basic_binary_tree.py (TheAlgorithms#748)
1 parent 15bc87f commit 56de3df

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

binary_tree/basic_binary_tree.py

+16
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ def __init__(self, data):
44
self.left = None
55
self.right = None
66

7+
def display(tree): #In Order traversal of the tree
8+
9+
if tree is None:
10+
return
11+
12+
if tree.left is not None:
13+
display(tree.left)
14+
15+
print(tree.data)
16+
17+
if tree.right is not None:
18+
display(tree.right)
19+
20+
return
721

822
def depth_of_tree(tree): #This is the recursive function to find the depth of binary tree.
923
if tree is None:
@@ -41,6 +55,8 @@ def main(): # Main func for testing.
4155

4256
print(is_full_binary_tree(tree))
4357
print(depth_of_tree(tree))
58+
print("Tree is: ")
59+
display(tree)
4460

4561

4662
if __name__ == '__main__':

0 commit comments

Comments
 (0)