Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Lines changed: 16 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /